Richard W.M. Jones
2017-Apr-03 15:19 UTC
[Libguestfs] [PATCH supermin] init: Don't perform ioctl (TIOCSCTTY).
Don't know why it works, but it works ... Rich.
Richard W.M. Jones
2017-Apr-03 15:19 UTC
[Libguestfs] [PATCH supermin] init: Don't perform ioctl (TIOCSCTTY).
Doing this breaks bash in virt-rescue with the error: bash: cannot set terminal process group (-1): Inappropriate ioctl for device bash: no job control in this shell Also ^C etc does not work. Removing this ioctl call fixes this. I noticed the problem because supermin's init compiled with dietlibc worked, since the dietlibc header files don't define TIOCSCTTY and hence the ioctl was not called. --- init/init.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/init/init.c b/init/init.c index e6fd0e6..aa6c25f 100644 --- a/init/init.c +++ b/init/init.c @@ -240,10 +240,6 @@ main () /* Make current process the controlling process of the tty. */ setsid (); -#ifdef TIOCSCTTY - if (ioctl (0, TIOCSCTTY, 1) == -1) - perror ("ioctl: TIOCSCTTY"); -#endif if (!quiet) fprintf (stderr, "supermin: creating /dev/root as block special %d:%d\n", -- 2.12.0
Richard W.M. Jones
2017-Apr-03 15:26 UTC
Re: [Libguestfs] [PATCH supermin] init: Don't perform ioctl (TIOCSCTTY).
On Mon, Apr 03, 2017 at 04:19:24PM +0100, Richard W.M. Jones wrote:> Doing this breaks bash in virt-rescue with the error: > > bash: cannot set terminal process group (-1): Inappropriate ioctl for device > bash: no job control in this shell > > Also ^C etc does not work. > > Removing this ioctl call fixes this. > > I noticed the problem because supermin's init compiled with dietlibc > worked, since the dietlibc header files don't define TIOCSCTTY and > hence the ioctl was not called. > --- > init/init.c | 4 ---- > 1 file changed, 4 deletions(-) > > diff --git a/init/init.c b/init/init.c > index e6fd0e6..aa6c25f 100644 > --- a/init/init.c > +++ b/init/init.c > @@ -240,10 +240,6 @@ main () > > /* Make current process the controlling process of the tty. */ > setsid ();I forgot to add that setsid() is also not necessary, but unlike the ioctl it doesn't seem to do any harm. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com libguestfs lets you edit virtual machines. Supports shell scripting, bindings from many languages. http://libguestfs.org
Seemingly Similar Threads
- [PATCH supermin] init: Don't perform ioctl (TIOCSCTTY).
- [PATCH supermin 0/2] Allow an alternate libc to be used for init.
- [PATCH supermin 0/2] Allow an alternate libc to be used for init.
- error: ioctl(TIOCSCTTY)
- Re: [PATCH supermin v2 4/4] init: Debug which libc is in use.