]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
Attempt to fix control tty issues on attach
authorStéphane Graber <stgraber@ubuntu.com>
Fri, 13 Mar 2015 20:43:16 +0000 (16:43 -0400)
committerStéphane Graber <stgraber@ubuntu.com>
Fri, 14 Aug 2015 16:50:14 +0000 (12:50 -0400)
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
src/lxc/attach.c

index 4504a5b538674cb25caf3fa3e0469cc411465dad..4a60cd299e3f629d78c7a8f11834fe5147b2a62f 100644 (file)
@@ -1074,6 +1074,21 @@ static int attach_child_main(void* data)
        if (options->gid != (gid_t)-1)
                new_gid = options->gid;
 
+       /* setup the control tty */
+       if (options->stdin_fd) {
+               if (setsid() < 0) {
+                       SYSERROR("unable to setsid");
+                       shutdown(ipc_socket, SHUT_RDWR);
+                       rexit(-1);
+               }
+
+               if (ioctl(options->stdin_fd, TIOCSCTTY, (char *)NULL) < 0) {
+                       SYSERROR("unable to TIOCSTTY");
+                       shutdown(ipc_socket, SHUT_RDWR);
+                       rexit(-1);
+               }
+       }
+
        /* try to set the uid/gid combination */
        if ((new_gid != 0 || options->namespaces & CLONE_NEWUSER)) {
                if (setgid(new_gid) || setgroups(0, NULL)) {