Skip to content
This repository was archived by the owner on Feb 8, 2021. It is now read-only.

Commit f705ed2

Browse files
authored
Merge pull request #331 from laijs/dev-console
bind mount the /dev/console
2 parents 2c60b7e + 00fe084 commit f705ed2

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/exec.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include <sys/epoll.h>
88
#include <sys/ioctl.h>
99
#include <sys/wait.h>
10+
#include <sys/mount.h>
1011
#include <sys/socket.h>
1112
#include <sys/eventfd.h>
1213
#include <dirent.h>
@@ -516,6 +517,20 @@ static int hyper_do_exec_cmd(struct hyper_exec *exec, int pid_efd, int process_i
516517
goto out;
517518
}
518519

520+
// from runtime-spec:
521+
// [`/dev/console`][console.4] is set up if terminal is enabled
522+
// in the config by bind mounting the pseudoterminal slave
523+
// to /dev/console.
524+
if (exec->init && exec->tty) {
525+
char ptyslave[32];
526+
527+
sprintf(ptyslave, "/dev/pts/%d", exec->ptyno);
528+
if (mount(ptyslave, "/dev/console", NULL, MS_BIND, NULL) < 0) {
529+
perror("fail to bind mount /dev/console");
530+
goto out;
531+
}
532+
}
533+
519534
// Make sure we start with a clean environment
520535
clearenv();
521536

0 commit comments

Comments
 (0)