syslog: fix incorrect use of sizeof() in vsnprintf()
[project/procd.git] / state.c
diff --git a/state.c b/state.c
index 618d758..90e883c 100644 (file)
--- a/state.c
+++ b/state.c
@@ -40,12 +40,14 @@ static void state_enter(void)
        switch (state) {
        case STATE_EARLY:
                LOG("- early -\n");
-               watchdog_init();
+               watchdog_init(0);
                hotplug("/etc/hotplug.json");
                procd_coldplug();
                break;
 
        case STATE_INIT:
+               // try to reopen incase the wdt was not available before coldplug
+               watchdog_init(0);
                LOG("- init -\n");
                log_init();
                procd_connect_ubus();
@@ -63,12 +65,11 @@ static void state_enter(void)
        case STATE_SHUTDOWN:
                LOG("- shutdown -\n");
                procd_inittab_run("shutdown");
+               sync();
                break;
 
        case STATE_HALT:
                LOG("- reboot -\n");
-               sync();
-               sleep(1);
                reboot(reboot_event);
                break;
 
@@ -87,7 +88,7 @@ void procd_state_next(void)
 
 void procd_shutdown(int event)
 {
-       DEBUG(1, "Shutting down system with event %x\n", reboot_event);
+       DEBUG(1, "Shutting down system with event %x\n", event);
        reboot_event = event;
        state = STATE_SHUTDOWN;
        state_enter();