diff options
author | Nicolas Douma <nicolas@serveur.io> | 2019-09-17 05:07:00 +0200 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2019-10-03 12:13:03 +0200 |
commit | de1b29f375b13b0566814517bf81e3cdbdd9a610 (patch) | |
tree | 61c2d909001ad79889df1beaee22cabca411e51e /src/nspawn | |
parent | 6e2d361d538f203a553f9848e364191bd576ff59 (diff) | |
download | systemd-de1b29f375b13b0566814517bf81e3cdbdd9a610.tar.gz |
nspawn: surrender controlling terminal to PID2 when using the PID1 stub
Diffstat (limited to 'src/nspawn')
-rw-r--r-- | src/nspawn/nspawn-stub-pid1.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/nspawn/nspawn-stub-pid1.c b/src/nspawn/nspawn-stub-pid1.c index ebf4f0f523..0589685afe 100644 --- a/src/nspawn/nspawn-stub-pid1.c +++ b/src/nspawn/nspawn-stub-pid1.c @@ -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"); |