nspawn: surrender controlling terminal to PID2 when using the PID1 stub

This commit is contained in:
Nicolas Douma 2019-09-17 05:07:00 +02:00 committed by Zbigniew Jędrzejewski-Szmek
parent 6e2d361d53
commit de1b29f375
1 changed files with 6 additions and 0 deletions

View File

@ -53,6 +53,12 @@ int stub_pid1(sd_id128_t uuid) {
assert_se(sigfillset(&fullmask) >= 0);
assert_se(sigprocmask(SIG_BLOCK, &fullmask, &oldmask) >= 0);
/* Surrender the terminal this stub may control so that child processes can have a controlling terminal
* without resorting to setsid hacks. */
r = ioctl(STDIN_FILENO, TIOCNOTTY);
if (r < 0 && errno != ENOTTY)
return log_error_errno(errno, "Failed to surrender controlling terminal: %m");
pid = fork();
if (pid < 0)
return log_error_errno(errno, "Failed to fork child pid: %m");