[PATCH] ash: setsid and TIOCSCTTY when enabling job control.
Michael Conrad
mconrad at intellitree.com
Tue Mar 13 00:09:02 UTC 2012
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)
-Mike
On 3/12/2012 7:56 PM, Avery Pennarun wrote:
> Both calls will fail if we are already a process group leader, or the
> process group leader is not us, or we already have a controlling terminal.
> So basically these calls are harmless in the worst case, and get rid of the
> annoying "can't access tty; job control turned off" problem in the best
> case. In other words, CTRL-C and CTRL-Z will work.
>
> This makes busybox sh job control usable with "init=/bin/sh" on the Linux
> kernel command line.
> ---
> shell/ash.c | 2 ++
> 1 files changed, 2 insertions(+), 0 deletions(-)
>
> diff --git a/shell/ash.c b/shell/ash.c
> index 5671a52..5259dd2 100644
> --- a/shell/ash.c
> +++ b/shell/ash.c
> @@ -3727,6 +3727,8 @@ setjobctl(int on)
> if (fd< 0)
> goto out;
> /* fd is a tty at this point */
> + setsid();
> + ioctl(fd, TIOCSCTTY, 0);
> close_on_exec_on(fd);
> do { /* while we are in the background */
> pgrp = tcgetpgrp(fd);
More information about the busybox
mailing list