Simplify shutdown/reboot when running in a container

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg committed 2022-03-01 20:46:01 +01:00
1 parent 6fa3aa41df
commit 2faefd44a2
1 file changed
+14 -6
+14 -6
View File
@@ -261,13 +261,16 @@ static int do_wait(int secs)
void do_shutdown(shutop_t op) void do_shutdown(shutop_t op)
{ {
struct sched_param sched_param = { .sched_priority = 99 }; struct sched_param sched_param = { .sched_priority = 99 };
int in_cont = in_container();
int signo = SIGTERM; int signo = SIGTERM;
/* if (!in_cont) {
* On a PREEMPT-RT system, Finit must run as the highest prioritized /*
* RT process to ensure it completes the shutdown sequence. * On a PREEMPT-RT system, Finit must run as the highest prioritized
*/ * RT process to ensure it completes the shutdown sequence.
sched_setscheduler(1, SCHED_RR, &sched_param); */
sched_setscheduler(1, SCHED_RR, &sched_param);
}
if (sdown) if (sdown)
run_interactive(sdown, "Calling shutdown hook: %s", sdown); run_interactive(sdown, "Calling shutdown hook: %s", sdown);
@@ -306,6 +309,11 @@ void do_shutdown(shutop_t op)
return; return;
} }
if (in_cont) {
sync();
goto done;
}
if (wdog) { if (wdog) {
print(kill(wdog->pid, SIGPWR) == 1, "Advising watchdog, system going down"); print(kill(wdog->pid, SIGPWR) == 1, "Advising watchdog, system going down");
do_sleep(2); do_sleep(2);
@@ -327,7 +335,7 @@ void do_shutdown(shutop_t op)
/* Call mdadm to mark any RAID array(s) as clean before halting. */ /* Call mdadm to mark any RAID array(s) as clean before halting. */
mdadm_wait(); mdadm_wait();
/* Reboot via watchdog or kernel, or shutdown? */ done: /* Reboot via watchdog or kernel, or shutdown? */
if (op == SHUT_REBOOT) { if (op == SHUT_REBOOT) {
if (wdog && wdog->pid > 1) { if (wdog && wdog->pid > 1) {
int timeout = 10; int timeout = 10;