[PATCH] ash: setsid and TIOCSCTTY when enabling job control.
Denys Vlasenko
vda.linux at googlemail.com
Tue Mar 13 03:16:25 UTC 2012
On Tuesday 13 March 2012 00:56, 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.
I don't think so. In this case, stdio is redirected to /dev/console.
In Linux, /dev/console can't be a controlling terminal.
> ---
> 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();
Creating new session for every interactive shell?
I have a feeling this is breaking a lot of things.
> + ioctl(fd, TIOCSCTTY, 0);
This *might* be ok....
> close_on_exec_on(fd);
> do { /* while we are in the background */
> pgrp = tcgetpgrp(fd);
--
vda
More information about the busybox
mailing list