aboutsummaryrefslogtreecommitdiff
path: root/init
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2017-11-03 14:16:08 +0000
committerRon Yorston <rmy@pobox.com>2017-11-03 14:16:08 +0000
commitd6ce08aeb85b3698ddaa281016b70e16aeb9fb35 (patch)
tree02ad9bc0684859515fe891f3d6b0a1086e0db156 /init
parentab450021a99ba66126cc6d668fb06ec3829a572b (diff)
parenta5060b8364faa7c677c8950f1315c451403b0660 (diff)
downloadbusybox-w32-d6ce08aeb85b3698ddaa281016b70e16aeb9fb35.tar.gz
busybox-w32-d6ce08aeb85b3698ddaa281016b70e16aeb9fb35.tar.bz2
busybox-w32-d6ce08aeb85b3698ddaa281016b70e16aeb9fb35.zip
Merge branch 'busybox' into merge
Diffstat (limited to 'init')
-rw-r--r--init/init.c39
1 files changed, 13 insertions, 26 deletions
diff --git a/init/init.c b/init/init.c
index 64e5c3e0b..6f3374eac 100644
--- a/init/init.c
+++ b/init/init.c
@@ -391,8 +391,10 @@ static int open_stdio_to_tty(const char* tty_name)
391 /* fd can be only < 0 or 0: */ 391 /* fd can be only < 0 or 0: */
392 fd = device_open(tty_name, O_RDWR); 392 fd = device_open(tty_name, O_RDWR);
393 if (fd) { 393 if (fd) {
394 message(L_LOG | L_CONSOLE, "can't open %s: %s", 394 message(L_LOG | L_CONSOLE, "can't open %s: "STRERROR_FMT,
395 tty_name, strerror(errno)); 395 tty_name
396 STRERROR_ERRNO
397 );
396 return 0; /* failure */ 398 return 0; /* failure */
397 } 399 }
398 dup2(STDIN_FILENO, STDOUT_FILENO); 400 dup2(STDIN_FILENO, STDOUT_FILENO);
@@ -469,7 +471,7 @@ static void init_exec(const char *command)
469 } 471 }
470 /* Here command never contains the dash, cmd[0] might */ 472 /* Here command never contains the dash, cmd[0] might */
471 BB_EXECVP(command, cmd); 473 BB_EXECVP(command, cmd);
472 message(L_LOG | L_CONSOLE, "can't run '%s': %s", command, strerror(errno)); 474 message(L_LOG | L_CONSOLE, "can't run '%s': "STRERROR_FMT, command STRERROR_ERRNO);
473 /* returns if execvp fails */ 475 /* returns if execvp fails */
474} 476}
475 477
@@ -1062,6 +1064,12 @@ int init_main(int argc UNUSED_PARAM, char **argv)
1062#endif 1064#endif
1063 1065
1064 if (!DEBUG_INIT) { 1066 if (!DEBUG_INIT) {
1067 /* Some users send poweroff signals to init VERY early.
1068 * To handle this, mask signals early,
1069 * and unmask them only after signal handlers are installed.
1070 */
1071 sigprocmask_allsigs(SIG_BLOCK);
1072
1065 /* Expect to be invoked as init with PID=1 or be invoked as linuxrc */ 1073 /* Expect to be invoked as init with PID=1 or be invoked as linuxrc */
1066 if (getpid() != 1 1074 if (getpid() != 1
1067 && (!ENABLE_LINUXRC || applet_name[0] != 'l') /* not linuxrc? */ 1075 && (!ENABLE_LINUXRC || applet_name[0] != 'l') /* not linuxrc? */
@@ -1104,29 +1112,6 @@ int init_main(int argc UNUSED_PARAM, char **argv)
1104 message(L_CONSOLE | L_LOG, "init started: %s", bb_banner); 1112 message(L_CONSOLE | L_LOG, "init started: %s", bb_banner);
1105#endif 1113#endif
1106 1114
1107#if 0
1108/* It's 2013, does anyone really still depend on this? */
1109/* If you do, consider adding swapon to sysinit actions then! */
1110/* struct sysinfo is linux-specific */
1111# ifdef __linux__
1112 /* Make sure there is enough memory to do something useful. */
1113 /*if (ENABLE_SWAPONOFF) - WRONG: we may have non-bbox swapon*/ {
1114 struct sysinfo info;
1115
1116 if (sysinfo(&info) == 0
1117 && (info.mem_unit ? info.mem_unit : 1) * (long long)info.totalram < 1024*1024
1118 ) {
1119 message(L_CONSOLE, "Low memory, forcing swapon");
1120 /* swapon -a requires /proc typically */
1121 new_init_action(SYSINIT, "mount -t proc proc /proc", "");
1122 /* Try to turn on swap */
1123 new_init_action(SYSINIT, "swapon -a", "");
1124 run_actions(SYSINIT); /* wait and removing */
1125 }
1126 }
1127# endif
1128#endif
1129
1130 /* Check if we are supposed to be in single user mode */ 1115 /* Check if we are supposed to be in single user mode */
1131 if (argv[1] 1116 if (argv[1]
1132 && (strcmp(argv[1], "single") == 0 || strcmp(argv[1], "-s") == 0 || LONE_CHAR(argv[1], '1')) 1117 && (strcmp(argv[1], "single") == 0 || strcmp(argv[1], "-s") == 0 || LONE_CHAR(argv[1], '1'))
@@ -1202,6 +1187,8 @@ int init_main(int argc UNUSED_PARAM, char **argv)
1202 + (1 << SIGHUP) /* reread /etc/inittab */ 1187 + (1 << SIGHUP) /* reread /etc/inittab */
1203#endif 1188#endif
1204 , record_signo); 1189 , record_signo);
1190
1191 sigprocmask_allsigs(SIG_UNBLOCK);
1205 } 1192 }
1206 1193
1207 /* Now run everything that needs to be run */ 1194 /* Now run everything that needs to be run */