chiark / gitweb /
unit: issue notify even if the high-level state didn't change
[elogind.git] / service.c
index 3d840cbd92f9c3c8a1cfa53d9e8de01b2f41edb2..c914ecace571ea7c7d00a7a49783487831fb0e81 100644 (file)
--- a/service.c
+++ b/service.c
@@ -839,7 +839,17 @@ static int service_load_pid_file(Service *s) {
         if ((unsigned long) (pid_t) p != p)
                 return -ERANGE;
 
-        s->main_pid = p;
+        if (kill((pid_t) p, 0) < 0 && errno != EPERM) {
+                log_warning("PID %llu read from file %s does not exist. Your service or init script might be broken.",
+                            (unsigned long long) p, s->pid_file);
+                return -ESRCH;
+        }
+
+        if ((r = unit_watch_pid(UNIT(s), (pid_t) p)) < 0)
+                /* FIXME: we need to do something here */
+                return r;
+
+        s->main_pid = (pid_t) p;
         s->main_pid_known = true;
 
         return 0;