[libvirt] lxc: setsid() usage

Daniel P. Berrange berrange at redhat.com
Mon Jun 22 14:51:24 UTC 2015


On Mon, Jun 22, 2015 at 04:40:37PM +0200, Richard Weinberger wrote:
> Hi!
> 
> Why is libvirt-lxc issuing a setsid() in lxcContainerSetupFDs()?
> To me it seems like a hack to have a controlling TTY if PID 1 is /bin/bash.

I honestly can't remember the reason. It might have been to ensure we have
separation from the libvirt_lxc session.

> If one runs a sysv init style distro (like Debian) in libvirt-lxc the setsid() has
> a major downside, when getty spawns a login shell on /dev/tty1 it cannot become
> the controlling tty. Hence, if one presses ctrl-c in such a session, the container will
> reboot.

Is that problem due to the fact we call setsid(), or due to use calling
ioctl(TIOCSCTTY) ?

> Interestingly it does not happen when a systemd distro is used.
> Maybe because systemd completely closes and reopens the TTY?

I have a feeling it does close & reopen the tty, but i dunno if
that has an impact on the ability to set the controlling tty ?

Also note systemd uses the device via /dev/console, not /dev/tty1
and with 'container_ttys' we've told it not to use /dev/tty1 for
gettys.  So maybe it deals with /dev/console in a different way
than it would if it were /dev/tty1

Regards,
Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|




More information about the libvir-list mailing list