Skip to content

Commit

Permalink
init: halt on SIGPWR too
Browse files Browse the repository at this point in the history
Most init processes implement a handler for SIGPWR that gracefully
stops all child processes when shutting down a machine. Some other
technologies rely on this signal - e.g. Busybox powered LXC
containers.

This patch makes busybox init halt when receiving SIGPWR.

Signed-off-by: Bogdan Purcareata <bogdan.purcareata@freescale.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
  • Loading branch information
Bogdan Purcareata authored and Denys Vlasenko committed Nov 26, 2013
1 parent cffe28e commit 760fc6d
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions init/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -789,7 +789,7 @@ static void run_shutdown_and_kill_processes(void)
* and only one will be remembered and acted upon.
*/

/* The SIGUSR[12]/SIGTERM handler */
/* The SIGPWR/SIGUSR[12]/SIGTERM handler */
static void halt_reboot_pwoff(int sig) NORETURN;
static void halt_reboot_pwoff(int sig)
{
Expand Down Expand Up @@ -1103,8 +1103,8 @@ int init_main(int argc UNUSED_PARAM, char **argv)

/* NOTE that if CONFIG_FEATURE_USE_INITTAB is NOT defined,
* then parse_inittab() simply adds in some default
* actions(i.e., INIT_SCRIPT and a pair
* of "askfirst" shells */
* actions (i.e., INIT_SCRIPT and a pair
* of "askfirst" shells) */
parse_inittab();
}

Expand Down Expand Up @@ -1135,6 +1135,7 @@ int init_main(int argc UNUSED_PARAM, char **argv)
struct sigaction sa;

bb_signals(0
+ (1 << SIGPWR) /* halt */
+ (1 << SIGUSR1) /* halt */
+ (1 << SIGTERM) /* reboot */
+ (1 << SIGUSR2) /* poweroff */
Expand Down

0 comments on commit 760fc6d

Please sign in to comment.