On Fri, 15 Sep 2000, Russell King wrote:
> There are two ways for a tty to become a controlling terminal:
>
> 1. First tty opened after a successful setsid() call.
> 2. using the TIOCSCTTY ioctl after a successful setsid() call.
>
> Both will only suceed if the current process does not already have a
> controlling terminal.
Both will fail for pid=1, which does not already have a controlling
terminal.
> Therefore...
>
> Richard B. Johnson writes:
> > setsid() = 6
> > open("/dev/tty1", O_RDWR|O_NONBLOCK) = 3
Look at his setsid() result. It is 6, so it was called from pid=6. Trust
me, it DOES NOT WORK for pid=1.
Adding a setsid() call at the very beginning of init() in init/main.c
makes pid=1 a process leader, at a time when it's still possible (no other
threads are running). After that, another kernel change can give it
/dev/console as its controlling terminal, or it can acquire the
controlling terminal itself via ioctl(0, TIOCSCTTY, 1).
Ion
-- It is better to keep your mouth shut and be thought a fool, than to open it and remove all doubt.- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org Please read the FAQ at http://www.tux.org/lkml/
This archive was generated by hypermail 2b29 : Fri Sep 15 2000 - 21:00:24 EST