chiark / gitweb /
execute: improve exec_spawn() logging
[elogind.git] / manager.c
index ddac4984acf324c8b5a00294d5a678f387bf67a0..9e4fbbbaeddd0d70973817bc0c76433de776dcf4 100644 (file)
--- a/manager.c
+++ b/manager.c
@@ -232,10 +232,24 @@ static int manager_find_paths(Manager *m) {
                                               NULL)))
                                 return -ENOMEM;
                 }
+
+                if ((e = getenv("SYSTEMD_SYSVRCND_PATH")))
+                        if (!(m->sysvrcnd_path = split_path_and_make_absolute(e)))
+                                return -ENOMEM;
+
+                if (strv_isempty(m->sysvrcnd_path)) {
+                        strv_free(m->sysvrcnd_path);
+
+                        if (!(m->sysvrcnd_path = strv_new(
+                                              SYSTEM_SYSVRCND_PATH,     /* /etc/rcN.d/ */
+                                              NULL)))
+                                return -ENOMEM;
+                }
         }
 
         strv_uniq(m->unit_path);
         strv_uniq(m->sysvinit_path);
+        strv_uniq(m->sysvrcnd_path);
 
         assert(!strv_isempty(m->unit_path));
         if (!(t = strv_join(m->unit_path, "\n\t")))
@@ -253,6 +267,16 @@ static int manager_find_paths(Manager *m) {
         } else
                 log_debug("Ignoring SysV init scripts.");
 
+        if (!strv_isempty(m->sysvrcnd_path)) {
+
+                if (!(t = strv_join(m->sysvrcnd_path, "\n\t")))
+                        return -ENOMEM;
+
+                log_debug("Looking for SysV rcN.d links in:\n\t%s", t);
+                free(t);
+        } else
+                log_debug("Ignoring SysV rcN.d links.");
+
         return 0;
 }
 
@@ -363,6 +387,7 @@ void manager_free(Manager *m) {
 
         strv_free(m->unit_path);
         strv_free(m->sysvinit_path);
+        strv_free(m->sysvrcnd_path);
 
         free(m->cgroup_controller);
         free(m->cgroup_hierarchy);
@@ -1389,8 +1414,6 @@ unsigned manager_dispatch_dbus_queue(Manager *m) {
 static int manager_dispatch_sigchld(Manager *m) {
         assert(m);
 
-        log_debug("dispatching SIGCHLD");
-
         for (;;) {
                 siginfo_t si;
                 Unit *u;
@@ -1415,6 +1438,8 @@ static int manager_dispatch_sigchld(Manager *m) {
                 if (!(u = hashmap_remove(m->watch_pids, UINT32_TO_PTR(si.si_pid))))
                         continue;
 
+                log_debug("child %llu belongs to %s", (long long unsigned) si.si_pid, unit_id(u));
+
                 UNIT_VTABLE(u)->sigchld_event(u, si.si_pid, si.si_code, si.si_status);
         }
 
@@ -1442,9 +1467,16 @@ static int manager_process_signal_fd(Manager *m, bool *quit) {
 
                 switch (sfsi.ssi_signo) {
 
-                case SIGCHLD:
+                case SIGCHLD: {
+                        char *name = NULL;
+
+                        get_process_name(sfsi.ssi_pid, &name);
+                        log_debug("Got SIGCHLD for process %llu (%s)", (unsigned long long) sfsi.ssi_pid, strna(name));
+                        free(name);
+
                         sigchld = true;
                         break;
+                }
 
                 case SIGINT:
                 case SIGTERM: