ryantimwilson / rpms / systemd

Forked from rpms/systemd a month ago
Clone
923a60
From 6f755a0934a1806a187076f9757064d3e973d1d2 Mon Sep 17 00:00:00 2001
923a60
From: Benjamin Robin <dev@benjarobin.fr>
923a60
Date: Sat, 19 Sep 2015 21:57:51 +0200
923a60
Subject: [PATCH] systemd-notify: Always pass a valid pid to sd_pid_notify
923a60
923a60
If the option --pid was used, take the pid from this option, unless take
923a60
the parend pid. Using 0 as pid (ucred of systemd-notify) will result 99% of the
923a60
time in a failure with this error: "Cannot find unit for notify message of PID"
923a60
923a60
Shouldn't we use always the ppid, since the MAINPID is something else ?
923a60
923a60
Signed-off-by: Benjamin Robin <dev@benjarobin.fr>
923a60
923a60
Cherry-picked from: 9de009a9
923a60
Resolves: #1381743
923a60
---
923a60
 src/notify/notify.c | 2 +-
923a60
 1 file changed, 1 insertion(+), 1 deletion(-)
923a60
923a60
diff --git a/src/notify/notify.c b/src/notify/notify.c
923a60
index c89a6cc063..0d382992a5 100644
923a60
--- a/src/notify/notify.c
923a60
+++ b/src/notify/notify.c
923a60
@@ -209,7 +209,7 @@ int main(int argc, char* argv[]) {
923a60
                 goto finish;
923a60
         }
923a60
 
923a60
-        r = sd_pid_notify(arg_pid, false, n);
923a60
+        r = sd_pid_notify(arg_pid ? arg_pid : getppid(), false, n);
923a60
         if (r < 0) {
923a60
                 log_error_errno(r, "Failed to notify init system: %m");
923a60
                 goto finish;