Fix procd not handling rapid reboot signals very well
[project/procd.git] / state.c
diff --git a/state.c b/state.c
index 9f3033b..bba5966 100644 (file)
--- a/state.c
+++ b/state.c
@@ -37,6 +37,7 @@ static int reboot_event;
 
 static void state_enter(void)
 {
+       char ubus_cmd[] = "/sbin/ubusd";
 
        switch (state) {
        case STATE_EARLY:
@@ -54,7 +55,7 @@ static void state_enter(void)
 
                LOG("- init -\n");
                service_init();
-               service_start_early("ubus", "/sbin/ubusd");
+               service_start_early("ubus", ubus_cmd);
 
                procd_inittab();
                procd_inittab_run("respawn");
@@ -93,6 +94,8 @@ void procd_state_next(void)
 
 void procd_shutdown(int event)
 {
+       if (state >= STATE_SHUTDOWN)
+               return;
        DEBUG(2, "Shutting down system with event %x\n", event);
        reboot_event = event;
        state = STATE_SHUTDOWN;