chiark / gitweb /
core: check for return value from get_process_state
[elogind.git] / src / core / service.c
index 5c6b638650198a1575ef944786e1344570c99a90..8e07bd0170c187513812185b1e21dac8fa7f41ba 100644 (file)
@@ -1376,6 +1376,20 @@ static int service_load_pid_file(Service *s, bool may_warn) {
                 return -ESRCH;
         }
 
+        r = get_process_state(pid);
+        if (r < 0) {
+                if (may_warn)
+                        log_info_unit(UNIT(s)->id, "Failed to read /proc/%d/stat: %s",
+                                      pid, strerror(-r));
+                return r;
+        } else if (r == '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;
@@ -3354,7 +3368,7 @@ static void service_notify_message(Unit *u, pid_t pid, char **tags) {
                 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_warning_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);
+                        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;
         }