From: Stéphane Graber Date: Fri, 13 Mar 2015 20:43:16 +0000 (-0400) Subject: Attempt to fix control tty issues on attach X-Git-Tag: lxc-1.1.1~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=49b8b13d1d61dbffd2c4bb19c03b8a746e11d902;p=thirdparty%2Flxc.git Attempt to fix control tty issues on attach Signed-off-by: Stéphane Graber Acked-by: Serge E. Hallyn --- diff --git a/src/lxc/attach.c b/src/lxc/attach.c index f70e42e8e..faa90fcb9 100644 --- a/src/lxc/attach.c +++ b/src/lxc/attach.c @@ -984,6 +984,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)) {