From 9c6bc7373e9b1956c9becd6c62e2a397c6d20aa6 Mon Sep 17 00:00:00 2001 From: Leah Neukirchen Date: Sat, 6 Jan 2024 23:13:25 +0100 Subject: run rc.boot/finish at the start of shutdown --- nitro.c | 37 +++++++++++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 8 deletions(-) diff --git a/nitro.c b/nitro.c index ac9212d..001d945 100644 --- a/nitro.c +++ b/nitro.c @@ -832,6 +832,18 @@ own_console() ioctl(0, TIOCSCTTY, 1); } +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) { @@ -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; } -- cgit 1.4.1