chiark / gitweb /
core: fix detection of dead processes
[elogind.git] / src / core / service.c
index 8c47e24bfb9673044fb830caff477c3cf0d6de4b..3a2ef015708311fd6bb3a0a838428c8504eb5407 100644 (file)
@@ -1376,6 +1376,14 @@ static int service_load_pid_file(Service *s, bool may_warn) {
                 return -ESRCH;
         }
 
+        if (get_process_state(pid) == 'Z') {
+                if (may_warn)
+                        log_info_unit(UNIT(s)->id,
+                                      "PID "PID_FMT" read from file %s is a zombie.",
+                                      pid, s->pid_file);
+                return -ESRCH;
+        }
+
         if (s->main_pid_known) {
                 if (pid == s->main_pid)
                         return 0;
@@ -3349,10 +3357,12 @@ static void service_notify_message(Unit *u, pid_t pid, char **tags) {
                 return;
         }
 
-        if (s->notify_access == NOTIFY_MAIN && s->main_pid != 0 && pid != s->main_pid) {
-                log_warning_unit(u->id,
-                                 "%s: Got notification message from PID "PID_FMT", but reception only permitted for PID "PID_FMT,
-                                 u->id, pid, s->main_pid);
+        if (s->notify_access == NOTIFY_MAIN && pid != s->main_pid) {
+
+                if (s->main_pid != 0)
+                        log_warning_unit(u->id, "%s: Got notification message from PID "PID_FMT", but reception only permitted for main PID "PID_FMT, u->id, pid, s->main_pid);
+                else
+                        log_debug_unit(u->id, "%s: Got notification message from PID "PID_FMT", but reception only permitted for main PID which is currently not known", u->id, pid);
                 return;
         }