]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
lxc: Don't make container's TTY a controlling TTY
authorRichard Weinberger <richard@nod.at>
Tue, 23 Jun 2015 13:18:53 +0000 (15:18 +0200)
committerDaniel P. Berrange <berrange@redhat.com>
Wed, 18 Nov 2015 11:22:33 +0000 (11:22 +0000)
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 init=/bin/bash.
To get a controlling TTY for bash just run "setsid /bin/bash".

Signed-off-by: Richard Weinberger <richard@nod.at>
src/lxc/lxc_container.c

index 6dc2ec768ffea14bff1ce483556d9f4c51c700dc..c9c2c458cf28d3bd8cddb08d7742f87f3bfca9aa 100644 (file)
@@ -279,18 +279,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"));
@@ -2231,7 +2219,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"),