aboutsummaryrefslogtreecommitdiff
path: root/init
diff options
context:
space:
mode:
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 */