Userspace does not expect that the initial console is a controlling TTY. systemd can deal with that, others not. On sysv init distros getty will fail to spawn a controlling on /dev/console or /dev/tty1. Which will cause to whole container to reboot upon ctrl-c. This patch changes the behavior of libvirt to match the kernel behavior where the initial TTY is also not controlling. The only user visible change should be that a container with bash as PID 1 would complain. But this matches exactly the kernel be behavior with intit=/bin/bash. To get a controlling TTY for bash just run "setsid /bin/bash". Signed-off-by: Richard Weinberger <richard@xxxxxx> --- src/lxc/lxc_container.c | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c index 11e9514..7d531e2 100644 --- a/src/lxc/lxc_container.c +++ b/src/lxc/lxc_container.c @@ -278,18 +278,6 @@ static int lxcContainerSetupFDs(int *ttyfd, "as the FDs are about to be closed for exec of " "the container init process"); - if (setsid() < 0) { - virReportSystemError(errno, "%s", - _("setsid failed")); - goto cleanup; - } - - if (ioctl(*ttyfd, TIOCSCTTY, NULL) < 0) { - virReportSystemError(errno, "%s", - _("ioctl(TIOCSCTTY) failed")); - goto cleanup; - } - if (dup2(*ttyfd, STDIN_FILENO) < 0) { virReportSystemError(errno, "%s", _("dup2(stdin) failed")); @@ -2210,7 +2198,7 @@ static int lxcContainerChild(void *data) VIR_DEBUG("Container TTY path: %s", ttyPath); - ttyfd = open(ttyPath, O_RDWR|O_NOCTTY); + ttyfd = open(ttyPath, O_RDWR); if (ttyfd < 0) { virReportSystemError(errno, _("Failed to open tty %s"), -- 2.4.2 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list