chiark / gitweb /
main: move basic setup into main.c
[elogind.git] / manager.c
index 87941e3f56f4dfab2d2ac65f38b1e81dc8f28dd0..7d3b8b503922d55a54880d28ca5eb6f227e0c614 100644 (file)
--- a/manager.c
+++ b/manager.c
@@ -49,8 +49,6 @@ static int manager_setup_signals(Manager *m) {
 
         assert(m);
 
-        assert_se(reset_all_signal_handlers() == 0);
-
         assert_se(sigemptyset(&mask) == 0);
         assert_se(sigaddset(&mask, SIGCHLD) == 0);
         assert_se(sigaddset(&mask, SIGINT) == 0);   /* Kernel sends us this on control-alt-del */
@@ -300,23 +298,15 @@ int manager_new(Manager **_m) {
         if ((r = manager_find_paths(m)) < 0)
                 goto fail;
 
-        if (chdir("/") < 0)
-                log_warning("Failed to chdir to /: %s", strerror(errno));
-
-        /* Become a session leader if we aren't one yet. */
-        setsid();
-
         if ((r = manager_setup_signals(m)) < 0)
                 goto fail;
 
-        if ((r = mount_setup()) < 0)
-                goto fail;
-
         if ((r = manager_setup_cgroup(m)) < 0)
                 goto fail;
 
-        /* FIXME: this should be called only when the D-Bus bus daemon is running */
-        if ((r = bus_init(m)) < 0)
+        /* Try to connect to the busses, if possible. */
+        if ((r = bus_init_system(m)) < 0 ||
+            (r = bus_init_api(m)) < 0)
                 goto fail;
 
         *_m = m;
@@ -364,7 +354,8 @@ void manager_free(Manager *m) {
 
         manager_shutdown_cgroup(m);
 
-        bus_done(m);
+        bus_done_api(m);
+        bus_done_system(m);
 
         hashmap_free(m->units);
         hashmap_free(m->jobs);
@@ -1498,6 +1489,16 @@ static int manager_process_signal_fd(Manager *m, bool *quit) {
 
                         break;
 
+                case SIGUSR1:
+
+                        printf("→ By units:\n");
+                        manager_dump_units(m, stdout, "\t");
+
+                        printf("→ By jobs:\n");
+                        manager_dump_jobs(m, stdout, "\t");
+
+                        break;
+
                 default:
                         log_info("Got unhandled signal <%s>.", strsignal(sfsi.ssi_signo));
                 }