about summary refs log tree commit diff
diff options
context:
space:
mode:
authorLeah Neukirchen <leah@vuxu.org>2024-01-06 23:13:25 +0100
committerLeah Neukirchen <leah@vuxu.org>2024-01-06 23:13:25 +0100
commit9c6bc7373e9b1956c9becd6c62e2a397c6d20aa6 (patch)
tree90c54c47f19de3ba35c6e6599bbfe17fbdc1ed9b
parent01361b4228734c36a4543f59b18d6bcb966ebc3c (diff)
downloadnitro-9c6bc7373e9b1956c9becd6c62e2a397c6d20aa6.tar.gz
nitro-9c6bc7373e9b1956c9becd6c62e2a397c6d20aa6.tar.xz
nitro-9c6bc7373e9b1956c9becd6c62e2a397c6d20aa6.zip
run rc.boot/finish at the start of shutdown
-rw-r--r--nitro.c37
1 files changed, 29 insertions, 8 deletions
diff --git a/nitro.c b/nitro.c
index ac9212d..001d945 100644
--- a/nitro.c
+++ b/nitro.c
@@ -833,6 +833,18 @@ own_console()
 }
 
 void
+do_stop_services() {
+	for (int i = 0; i < max_service; i++) {
+		if (services[i].islog)
+			continue;
+		if (strcmp(services[i].name, "LOG") == 0)
+			continue;
+
+		process_step(i, EVNT_WANT_DOWN);
+	}
+}
+
+void
 do_shutdown(int state)
 {
 	if (global_state == GLBL_UP) {
@@ -846,17 +858,22 @@ do_shutdown(int state)
 #ifdef __linux__
 		reboot(RB_ENABLE_CAD);
 #endif
-	}
 
-	global_state = state;
-	for (int i = 0; i < max_service; i++) {
-		if (services[i].islog)
-			continue;
-		if (strcmp(services[i].name, "LOG") == 0)
-			continue;
+		global_state = state;
 
-		process_step(i, EVNT_WANT_DOWN);
+
+		struct stat st;
+		if (stat("rc.boot", &st) == 0) {
+			int b = add_service("rc.boot");
+			services[b].state = PROC_ONESHOT;
+			process_step(b, EVNT_WANT_DOWN);
+			services[b].timeout = 30000;
+		} else {
+			do_stop_services();
+		}
 	}
+
+	global_state = state;
 }
 
 void
@@ -1140,6 +1157,10 @@ has_died(pid_t pid, int status)
 			    services[i].name, pid, status);
 			services[i].finishpid = 0;
 			process_step(i, EVNT_FINISHED);
+
+			if (strcmp(services[i].name, "rc.boot") == 0)
+				do_stop_services();
+
 			return;
 		}