chiark / gitweb /
fix machinectl shell (in machined) (#7785)
authorShawn Landden <slandden@gmail.com>
Thu, 4 Jan 2018 11:37:15 +0000 (03:37 -0800)
committerSven Eden <yamakuzure@gmx.net>
Wed, 30 May 2018 05:49:49 +0000 (07:49 +0200)
4c253ed broke machined
$machinectl shell arch
Failed to get shell PTY: Input/output error

Closes: #7779
v2: do not drop DEATHSIG flag

src/basic/process-util.c

index cb92bab0f51aa347b0b158d94700936a8e608972..940302e6feb25629d56712db8dbbfee7a010628e 100644 (file)
@@ -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);