From b12c52d40f2221e6e2b3ae0296d45c607845ea2a Mon Sep 17 00:00:00 2001 From: Rin Cat Date: Sat, 26 Dec 2020 00:38:11 -0500 Subject: Support docker and lxc stop This fixes #398. --- src/rc/openrc-init.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/rc/openrc-init.c') diff --git a/src/rc/openrc-init.c b/src/rc/openrc-init.c index c32259f7..c27e2086 100644 --- a/src/rc/openrc-init.c +++ b/src/rc/openrc-init.c @@ -207,6 +207,12 @@ static void signal_handler(int sig) case SIGINT: handle_shutdown("reboot", RB_AUTOBOOT); break; + case SIGTERM: +#ifdef SIGPWR + case SIGPWR: +#endif + handle_shutdown("shutdown", RB_HALT_SYSTEM); + break; case SIGCHLD: reap_zombies(); break; @@ -269,6 +275,10 @@ int main(int argc, char **argv) sigfillset(&signals); sigdelset(&signals, SIGCHLD); sigdelset(&signals, SIGINT); + sigdelset(&signals, SIGTERM); +#ifdef SIGPWR + sigdelset(&signals, SIGPWR); +#endif sigprocmask(SIG_SETMASK, &signals, NULL); /* install signal handler */ @@ -276,6 +286,10 @@ int main(int argc, char **argv) sa.sa_handler = signal_handler; sigaction(SIGCHLD, &sa, NULL); sigaction(SIGINT, &sa, NULL); + sigaction(SIGTERM, &sa, NULL); +#ifdef SIGPWR + sigaction(SIGPWR, &sa, NULL); +#endif reboot(RB_DISABLE_CAD); /* set default path */ -- cgit v1.2.3