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