On Mon, 31 Oct 2011 13:21:01 +0100, Denys Vlasenko <[email protected]> wrote: > On Mon, Oct 31, 2011 at 12:25 PM, Denys Vlasenko > <[email protected]> wrote: > > On Mon, Oct 31, 2011 at 1:15 AM, Alexander Shishkin <[email protected]> > > wrote: > >> Sometimes there's a need to figure out the controlling tty from a shell > >> script, for example, to obtain a line for getty. > >> In this case it's easier > >> to call cttyhack than trying to repeat some of the cttyhack's logic. > > > > "cttyhack getty 0 -" should work, right? > > > > > >> + /* If it's a /dev/tty, still make sure it's wired to > >> std{in,out,err} */ > >> + fd = open_or_warn(console, O_RDWR); > >> + if (fd < 0) > >> + goto ret; > >> + //bb_error_msg("switching to '%s'", console); > >> + dup2(fd, STDIN_FILENO); > >> + dup2(fd, STDOUT_FILENO); > >> + xmove_fd(fd, STDERR_FILENO); > > > > Think what would happen if fd = 1 > > Fixed it and applied to git. Thanks.
Thanks, except for now there is a problem with the serial test going before the sysfs test, and the former is almost never accurate as very few serial drivers use "ttyS" names these days. I'd say that the sysfs test is the most relevant for the cttyhack purposes. Regards, -- Alex _______________________________________________ busybox mailing list [email protected] http://lists.busybox.net/mailman/listinfo/busybox
