Unverified Commit 74941f9a by Li Feng Committed by Christian Brauner

start: dup std{in,out,err} to pty slave

In the case the container has a console with a valid slave pty file descriptor we duplicate std{in,out,err} to the slave file descriptor so console logging works correctly. Also, we should become session leader. Closes #1646. Closes #1951. Signed-off-by: 's avatarLi Feng <lifeng68@huawei.com> Signed-off-by: 's avatarChristian Brauner <christian.brauner@ubuntu.com>
parent d1ea3f93
......@@ -751,8 +751,13 @@ static int do_start(void *data)
* setup on its console ie. the pty allocated in lxc_console_create()
* so make sure that that pty is stdin,stdout,stderr.
*/
if (lxc_console_set_stdfds(handler->conf->console.slave) < 0)
goto out_warn_father;
if (handler->conf->console.slave >= 0)
if (set_stdfds(handler->conf->console.slave) < 0) {
ERROR("Failed to redirect std{in,out,err} to pty file "
"descriptor %d",
handler->conf->console.slave);
goto out_warn_father;
}
/* If we mounted a temporary proc, then unmount it now */
tmp_proc_unmount(handler->conf);
......@@ -782,8 +787,11 @@ static int do_start(void *data)
close(handler->sigfd);
/* after this call, we are in error because this
* ops should not return as it execs */
setsid();
/* After this call, we are in error because this ops should not return
* as it execs.
*/
handler->ops->start(handler, handler->data);
out_warn_father:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment