about summary refs log tree commit diff
path: root/nitro.c
diff options
context:
space:
mode:
authorLeah Neukirchen <leah@vuxu.org>2023-12-25 02:40:41 +0100
committerLeah Neukirchen <leah@vuxu.org>2023-12-25 02:41:33 +0100
commitd8412bf0b2ead0fdcc32815362463c577e0b8c0e (patch)
treec14a75f1998e95b31fa0cc2818c9fd4f8eb1ae1d /nitro.c
parent8d818d9daccaf12335943f886af9e7f6184af5ad (diff)
downloadnitro-d8412bf0b2ead0fdcc32815362463c577e0b8c0e.tar.gz
nitro-d8412bf0b2ead0fdcc32815362463c577e0b8c0e.tar.xz
nitro-d8412bf0b2ead0fdcc32815362463c577e0b8c0e.zip
message reboot/shutdown only once
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