Messages in this thread |  | | From | Russell King <> | Subject | Re: Booting into /bin/bash | Date | Fri, 15 Sep 2000 00:58:59 +0100 (BST) |
| |
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.
(Note that TIOCSCTTY takes an argument which means "steal the controlling tty from another session leader, if any" which only works if the calling process is UID0).
Therefore...
Richard B. Johnson writes: > setsid() = 6 > open("/dev/tty1", O_RDWR|O_NONBLOCK) = 3
at this point, tty1 is your controlling terminal (by condition 1 above), and
> fcntl(3, F_GETFL) = 0x802 (flags O_RDWR|O_NONBLOCK) > fcntl(3, F_SETFL, O_RDWR) = 0 > dup2(3, 0) = 0 > dup2(3, 1) = 1 > dup2(3, 2) = 2 > ioctl(3, TIOCSCTTY) = -1 EPERM (Operation not permitted)
fails because you already have a controlling terminal.
Read: drivers/char/tty_io.c:tiocsctty drivers/char/tty_io.c:tty_open kernel/sys.c:sys_setsid
for more information and enlightenment. _____ |_____| ------------------------------------------------- ---+---+- | | Russell King rmk@arm.linux.org.uk --- --- | | | | http://www.arm.linux.org.uk/personal/aboutme.html / / | | +-+-+ --- -+- / | THE developer of ARM Linux |+| /|\ / | | | --- | +-+-+ ------------------------------------------------- /\\\ | - 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/
|  |