chiark / gitweb /
execute: improve exec_spawn() logging
[elogind.git] / service.c
index 74d03dbe1d4c26693b7db0ddc4049b08386e7cc1..e5a9658bcfa7784edef26acb0cf17f917998c194 100644 (file)
--- a/service.c
+++ b/service.c
@@ -157,7 +157,10 @@ static int sysv_chkconfig_order(Service *s) {
                 if (t->sysv_start_priority < 0)
                         continue;
 
-                if (s->sysv_has_lsb && t->sysv_has_lsb)
+                /* If both units have modern headers we don't care
+                 * about the priorities */
+                if ((!s->sysv_path || s->sysv_has_lsb) &&
+                    (!t->sysv_path || t->sysv_has_lsb))
                         continue;
 
                 if (t->sysv_start_priority < s->sysv_start_priority)
@@ -768,6 +771,16 @@ static void service_dump(Unit *u, FILE *f, const char *prefix) {
                 prefix, kill_mode_to_string(s->kill_mode),
                 prefix, service_type_to_string(s->type));
 
+        if (s->control_pid > 0)
+                fprintf(f,
+                        "%sControl PID: %llu\n",
+                        prefix, (unsigned long long) s->control_pid);
+
+        if (s->main_pid > 0)
+                fprintf(f,
+                        "%sMain PID: %llu\n",
+                        prefix, (unsigned long long) s->main_pid);
+
         if (s->pid_file)
                 fprintf(f,
                         "%sPIDFile: %s\n",
@@ -829,7 +842,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;