[PATCH] cttyhack: print detected ctty name when called without parameters
Denys Vlasenko
vda.linux at googlemail.com
Mon Oct 31 11:25:58 UTC 2011
On Mon, Oct 31, 2011 at 1:15 AM, Alexander Shishkin <virtuoso at slind.org> 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
--
vda
More information about the busybox
mailing list