From 00fe08485ed9d82bff6f23d0534943a20051d6f2 Mon Sep 17 00:00:00 2001 From: Lai Jiangshan Date: Fri, 1 Sep 2017 15:44:49 +0800 Subject: [PATCH] bind mount the /dev/console Signed-off-by: Lai Jiangshan --- src/exec.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/exec.c b/src/exec.c index 7faf092b..893485b1 100644 --- a/src/exec.c +++ b/src/exec.c @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include @@ -516,6 +517,20 @@ static int hyper_do_exec_cmd(struct hyper_exec *exec, int pid_efd, int process_i goto out; } + // from runtime-spec: + // [`/dev/console`][console.4] is set up if terminal is enabled + // in the config by bind mounting the pseudoterminal slave + // to /dev/console. + if (exec->init && exec->tty) { + char ptyslave[32]; + + sprintf(ptyslave, "/dev/pts/%d", exec->ptyno); + if (mount(ptyslave, "/dev/console", NULL, MS_BIND, NULL) < 0) { + perror("fail to bind mount /dev/console"); + goto out; + } + } + // Make sure we start with a clean environment clearenv();