[PATCH] ash: setsid and TIOCSCTTY when enabling job control.
Avery Pennarun
apenwarr at gmail.com
Tue Mar 13 00:18:58 UTC 2012
On Mon, Mar 12, 2012 at 8:09 PM, Michael Conrad <mconrad at intellitree.com> wrote:
> Would this have an effect on scripts being used as init which did not
> previously have a controlling terminal? There are quite a few commands
> which change behavior when run with/without a tty.
>
> (the usual fix for enabling job control is to run agetty in your init
> script)
It should be fine. TIOCSCTTY only works if you're the session leader,
which is the result of setsid(). And setsid() only works if there is
not already a session leader for this terminal. Together, this means
neither call will do anything if there's already a controlling
terminal.
Note also that none of this code even runs until the shell tries to
enable job control, which scripts wouldn't be doing (if they did,
you'd see the "can't access tty; job control turned off" message more
often).
Have fun,
Avery
More information about the busybox
mailing list