aboutsummaryrefslogtreecommitdiff
path: root/init/init.c
diff options
context:
space:
mode:
Diffstat (limited to 'init/init.c')
-rw-r--r--init/init.c32
1 files changed, 20 insertions, 12 deletions
diff --git a/init/init.c b/init/init.c
index edb5be696..d29328c36 100644
--- a/init/init.c
+++ b/init/init.c
@@ -9,11 +9,6 @@
9 * Licensed under GPLv2 or later, see file LICENSE in this source tree. 9 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
10 */ 10 */
11 11
12//applet:IF_INIT(APPLET(init, BB_DIR_SBIN, BB_SUID_DROP))
13//applet:IF_FEATURE_INITRD(APPLET_ODDNAME(linuxrc, init, BB_DIR_ROOT, BB_SUID_DROP, linuxrc))
14
15//kbuild:lib-$(CONFIG_INIT) += init.o
16
17//config:config INIT 12//config:config INIT
18//config: bool "init" 13//config: bool "init"
19//config: default y 14//config: default y
@@ -108,6 +103,11 @@
108//config: Note that on Linux, init attempts to detect serial terminal and 103//config: Note that on Linux, init attempts to detect serial terminal and
109//config: sets TERM to "vt102" if one is found. 104//config: sets TERM to "vt102" if one is found.
110 105
106//applet:IF_INIT(APPLET(init, BB_DIR_SBIN, BB_SUID_DROP))
107//applet:IF_FEATURE_INITRD(APPLET_ODDNAME(linuxrc, init, BB_DIR_ROOT, BB_SUID_DROP, linuxrc))
108
109//kbuild:lib-$(CONFIG_INIT) += init.o
110
111#define DEBUG_SEGV_HANDLER 0 111#define DEBUG_SEGV_HANDLER 0
112 112
113#include "libbb.h" 113#include "libbb.h"
@@ -222,8 +222,8 @@ static void message(int where, const char *fmt, ...)
222 msg[0] = '\r'; 222 msg[0] = '\r';
223 va_start(arguments, fmt); 223 va_start(arguments, fmt);
224 l = 1 + vsnprintf(msg + 1, sizeof(msg) - 2, fmt, arguments); 224 l = 1 + vsnprintf(msg + 1, sizeof(msg) - 2, fmt, arguments);
225 if (l > sizeof(msg) - 1) 225 if (l > sizeof(msg) - 2)
226 l = sizeof(msg) - 1; 226 l = sizeof(msg) - 2;
227 va_end(arguments); 227 va_end(arguments);
228 228
229#if ENABLE_FEATURE_INIT_SYSLOG 229#if ENABLE_FEATURE_INIT_SYSLOG
@@ -789,7 +789,7 @@ static void run_shutdown_and_kill_processes(void)
789 * and only one will be remembered and acted upon. 789 * and only one will be remembered and acted upon.
790 */ 790 */
791 791
792/* The SIGUSR[12]/SIGTERM handler */ 792/* The SIGPWR/SIGUSR[12]/SIGTERM handler */
793static void halt_reboot_pwoff(int sig) NORETURN; 793static void halt_reboot_pwoff(int sig) NORETURN;
794static void halt_reboot_pwoff(int sig) 794static void halt_reboot_pwoff(int sig)
795{ 795{
@@ -1103,8 +1103,8 @@ int init_main(int argc UNUSED_PARAM, char **argv)
1103 1103
1104 /* NOTE that if CONFIG_FEATURE_USE_INITTAB is NOT defined, 1104 /* NOTE that if CONFIG_FEATURE_USE_INITTAB is NOT defined,
1105 * then parse_inittab() simply adds in some default 1105 * then parse_inittab() simply adds in some default
1106 * actions(i.e., INIT_SCRIPT and a pair 1106 * actions (i.e., INIT_SCRIPT and a pair
1107 * of "askfirst" shells */ 1107 * of "askfirst" shells) */
1108 parse_inittab(); 1108 parse_inittab();
1109 } 1109 }
1110 1110
@@ -1128,13 +1128,14 @@ int init_main(int argc UNUSED_PARAM, char **argv)
1128 strncpy(argv[0], "init", strlen(argv[0])); 1128 strncpy(argv[0], "init", strlen(argv[0]));
1129 /* Wipe argv[1]-argv[N] so they don't clutter the ps listing */ 1129 /* Wipe argv[1]-argv[N] so they don't clutter the ps listing */
1130 while (*++argv) 1130 while (*++argv)
1131 memset(*argv, 0, strlen(*argv)); 1131 nuke_str(*argv);
1132 1132
1133 /* Set up signal handlers */ 1133 /* Set up signal handlers */
1134 if (!DEBUG_INIT) { 1134 if (!DEBUG_INIT) {
1135 struct sigaction sa; 1135 struct sigaction sa;
1136 1136
1137 bb_signals(0 1137 bb_signals(0
1138 + (1 << SIGPWR) /* halt */
1138 + (1 << SIGUSR1) /* halt */ 1139 + (1 << SIGUSR1) /* halt */
1139 + (1 << SIGTERM) /* reboot */ 1140 + (1 << SIGTERM) /* reboot */
1140 + (1 << SIGUSR2) /* poweroff */ 1141 + (1 << SIGUSR2) /* poweroff */
@@ -1230,7 +1231,14 @@ int init_main(int argc UNUSED_PARAM, char **argv)
1230//usage:#define init_trivial_usage 1231//usage:#define init_trivial_usage
1231//usage: "" 1232//usage: ""
1232//usage:#define init_full_usage "\n\n" 1233//usage:#define init_full_usage "\n\n"
1233//usage: "Init is the parent of all processes" 1234//usage: "Init is the first process started during boot. It never exits."
1235//usage: IF_FEATURE_USE_INITTAB(
1236//usage: "\n""It (re)spawns children according to /etc/inittab."
1237//usage: )
1238//usage: IF_NOT_FEATURE_USE_INITTAB(
1239//usage: "\n""This version of init doesn't use /etc/inittab,"
1240//usage: "\n""has fixed set of processed to run."
1241//usage: )
1234//usage: 1242//usage:
1235//usage:#define init_notes_usage 1243//usage:#define init_notes_usage
1236//usage: "This version of init is designed to be run only by the kernel.\n" 1244//usage: "This version of init is designed to be run only by the kernel.\n"