diff options
author | Rin Cat <me@rin.cat> | 2020-12-26 00:38:11 -0500 |
---|---|---|
committer | William Hubbs <w.d.hubbs@gmail.com> | 2021-02-22 11:56:21 -0600 |
commit | b12c52d40f2221e6e2b3ae0296d45c607845ea2a (patch) | |
tree | a843c020a5a348658905080c427f617240c01171 /src/rc | |
parent | bac71fce5bc9cb7ba02338c6c4cfc949badd218b (diff) |
Support docker and lxc stop
This fixes #398.
Diffstat (limited to 'src/rc')
-rw-r--r-- | src/rc/openrc-init.c | 14 |
1 files changed, 14 insertions, 0 deletions
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 */ |