]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
c/r: detatch from controlling tty on restore 1204/head
authorTycho Andersen <tycho.andersen@canonical.com>
Wed, 21 Sep 2016 21:45:49 +0000 (21:45 +0000)
committerTycho Andersen <tycho.andersen@canonical.com>
Wed, 21 Sep 2016 21:46:20 +0000 (21:46 +0000)
Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
src/lxc/criu.c

index 3e586b9d5e168d85c8c32edf2d7d8a68e17eb104..67d6fdc5519b82102b85e81b9d108c546edddc66 100644 (file)
@@ -662,9 +662,22 @@ static void do_restore(struct lxc_container *c, int status_pipe, struct migrate_
 {
        pid_t pid;
        struct lxc_handler *handler;
-       int status;
+       int status, fd;
        int pipes[2] = {-1, -1};
 
+       /* Try to detach from the current controlling tty if it exists.
+        * Othwerise, lxc_init (via lxc_console) will attach the container's
+        * console output to the current tty, which is probably not what any
+        * library user wants, and if they do, they can just manually configure
+        * it :)
+        */
+       fd = open("/dev/tty", O_RDWR);
+       if (fd >= 0) {
+               if (ioctl(fd, TIOCNOTTY, NULL) < 0)
+                       SYSERROR("couldn't detach from tty");
+               close(fd);
+       }
+
        handler = lxc_init(c->name, c->lxc_conf, c->config_path);
        if (!handler)
                goto out;