aboutsummaryrefslogtreecommitdiff
path: root/init
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2017-11-02 15:25:28 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2017-11-02 15:25:28 +0100
commitf5e8b4278822f2413bf7e47466f55cc1a0fcca9a (patch)
tree831d2e2e32d4ede4dcb06be749d475ed72b868a3 /init
parent9c143ce52da11ec3d21a3491c3749841d3dc10f0 (diff)
downloadbusybox-f5e8b4278822f2413bf7e47466f55cc1a0fcca9a.tar.gz
init: reduce the window when init can lose reboot/poweroff signals
function old new delta init_main 695 712 +17 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'init')
-rw-r--r--init/init.c31
1 files changed, 8 insertions, 23 deletions
diff --git a/init/init.c b/init/init.c
index 5304e5c2c..6f3374eac 100644
--- a/init/init.c
+++ b/init/init.c
@@ -1064,6 +1064,12 @@ int init_main(int argc UNUSED_PARAM, char **argv)
#endif
if (!DEBUG_INIT) {
+ /* Some users send poweroff signals to init VERY early.
+ * To handle this, mask signals early,
+ * and unmask them only after signal handlers are installed.
+ */
+ sigprocmask_allsigs(SIG_BLOCK);
+
/* Expect to be invoked as init with PID=1 or be invoked as linuxrc */
if (getpid() != 1
&& (!ENABLE_LINUXRC || applet_name[0] != 'l') /* not linuxrc? */
@@ -1106,29 +1112,6 @@ int init_main(int argc UNUSED_PARAM, char **argv)
message(L_CONSOLE | L_LOG, "init started: %s", bb_banner);
#endif
-#if 0
-/* It's 2013, does anyone really still depend on this? */
-/* If you do, consider adding swapon to sysinit actions then! */
-/* struct sysinfo is linux-specific */
-# ifdef __linux__
- /* Make sure there is enough memory to do something useful. */
- /*if (ENABLE_SWAPONOFF) - WRONG: we may have non-bbox swapon*/ {
- struct sysinfo info;
-
- if (sysinfo(&info) == 0
- && (info.mem_unit ? info.mem_unit : 1) * (long long)info.totalram < 1024*1024
- ) {
- message(L_CONSOLE, "Low memory, forcing swapon");
- /* swapon -a requires /proc typically */
- new_init_action(SYSINIT, "mount -t proc proc /proc", "");
- /* Try to turn on swap */
- new_init_action(SYSINIT, "swapon -a", "");
- run_actions(SYSINIT); /* wait and removing */
- }
- }
-# endif
-#endif
-
/* Check if we are supposed to be in single user mode */
if (argv[1]
&& (strcmp(argv[1], "single") == 0 || strcmp(argv[1], "-s") == 0 || LONE_CHAR(argv[1], '1'))
@@ -1204,6 +1187,8 @@ int init_main(int argc UNUSED_PARAM, char **argv)
+ (1 << SIGHUP) /* reread /etc/inittab */
#endif
, record_signo);
+
+ sigprocmask_allsigs(SIG_UNBLOCK);
}
/* Now run everything that needs to be run */