about summary refs log tree commit diff
path: root/nitro.c
diff options
context:
space:
mode:
Diffstat (limited to 'nitro.c')
-rw-r--r--nitro.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/nitro.c b/nitro.c
index bc6b14e..ad437a8 100644
--- a/nitro.c
+++ b/nitro.c
@@ -712,10 +712,18 @@ own_console()
 void
 do_shutdown(int state)
 {
-	if (state == GLBL_WANT_REBOOT)
-		dprintf(2, "- nitro: rebooting\n");
-	else if (state == GLBL_WANT_SHUTDOWN)
-		dprintf(2, "- nitro: shutting down\n");
+	if (global_state == GLBL_UP) {
+		if (state == GLBL_WANT_REBOOT)
+			dprintf(2, "- nitro: rebooting\n");
+		else if (state == GLBL_WANT_SHUTDOWN)
+			dprintf(2, "- nitro: shutting down\n");
+
+		if (pid1)
+			own_console();
+#ifdef __linux__
+		reboot(RB_ENABLE_CAD);
+#endif
+	}
 
 	global_state = state;
 	for (int i = 0; i < max_service; i++) {
@@ -726,13 +734,6 @@ do_shutdown(int state)
 
 		process_step(i, EVNT_WANT_DOWN);
 	}
-
-	if (pid1)
-		own_console();
-
-#ifdef __linux__
-	reboot(RB_ENABLE_CAD);
-#endif
 }
 
 void