lkml.org 
[lkml]   [2000]   [Sep]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: Booting into /bin/bash
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/

\
 
 \ /
  Last update: 2005-03-22 12:38    [W:0.051 / U:4.572 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site