diff options
author | Shawn Landden <slandden@gmail.com> | 2018-01-04 03:37:15 -0800 |
---|---|---|
committer | Sven Eden <yamakuzure@gmx.net> | 2018-05-30 07:49:49 +0200 |
commit | b14c448a99421348d05777ac42490a1fe0f5fb31 (patch) | |
tree | ba7bc42df42aefa8988b062c56da6992bdee96a8 /src | |
parent | f2e564a3e0a57ff225102e8eb9b5f936e0c9f160 (diff) |
fix machinectl shell (in machined) (#7785)
4c253ed broke machined
$machinectl shell arch
Failed to get shell PTY: Input/output error
Closes: #7779
v2: do not drop DEATHSIG flag
Diffstat (limited to 'src')
-rw-r--r-- | src/basic/process-util.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/basic/process-util.c b/src/basic/process-util.c index cb92bab0f..940302e6f 100644 --- a/src/basic/process-util.c +++ b/src/basic/process-util.c @@ -1251,10 +1251,14 @@ int safe_fork_full( } if (flags & FORK_DEATHSIG) { + pid_t ppid; /* Let's see if the parent PID is still the one we started from? If not, then the parent * already died by the time we set PR_SET_PDEATHSIG, hence let's emulate the effect */ - if (getppid() != original_pid) { + ppid = getppid(); + if (ppid == 0) + /* Parent is in a differn't PID namespace. */; + else if (ppid != original_pid) { log_debug("Parent died early, raising SIGTERM."); (void) raise(SIGTERM); _exit(EXIT_FAILURE); |