[PATCH] cttyhack: print detected ctty name when called without parameters
Denys Vlasenko
vda.linux at googlemail.com
Mon Oct 31 15:58:09 UTC 2011
On Mon, Oct 31, 2011 at 4:10 PM, Alexander Shishkin <virtuoso at slind.org> wrote:
> On Mon, 31 Oct 2011 13:21:01 +0100, Denys Vlasenko <vda.linux at googlemail.com> wrote:
>> On Mon, Oct 31, 2011 at 12:25 PM, Denys Vlasenko
>> <vda.linux at googlemail.com> wrote:
>> > 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
>>
>> 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.
Then we need to stop lying that cttyhack "analyzes stdin with various ioctls"...
I restored the order of checks.
--
vda
More information about the busybox
mailing list