diff options
-rw-r--r-- | init/init.c | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/init/init.c b/init/init.c index 2040a59e8..25bfaec8c 100644 --- a/init/init.c +++ b/init/init.c | |||
@@ -102,6 +102,21 @@ | |||
102 | //config: | 102 | //config: |
103 | //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 |
104 | //config: sets TERM to "vt102" if one is found. | 104 | //config: sets TERM to "vt102" if one is found. |
105 | //config: | ||
106 | //config:config FEATURE_INIT_MODIFY_CMDLINE | ||
107 | //config: bool "Modify the command-line to \"init\"" | ||
108 | //config: default y | ||
109 | //config: depends on INIT | ||
110 | //config: help | ||
111 | //config: When launched as PID 1 and after parsing its arguments, init | ||
112 | //config: wipes all the arguments but argv[0] and rewrites argv[0] to | ||
113 | //config: contain only "init", so that its command-line appears solely as | ||
114 | //config: "init" in tools such as ps. | ||
115 | //config: If this option is set to Y, init will keep its original behavior, | ||
116 | //config: otherwise, all the arguments including argv[0] will be preserved, | ||
117 | //config: be they parsed or ignored by init. | ||
118 | //config: The original command-line used to launch init can then be | ||
119 | //config: retrieved in /proc/1/cmdline on Linux, for example. | ||
105 | 120 | ||
106 | //applet:IF_INIT(APPLET(init, BB_DIR_SBIN, BB_SUID_DROP)) | 121 | //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)) | 122 | //applet:IF_FEATURE_INITRD(APPLET_ODDNAME(linuxrc, init, BB_DIR_ROOT, BB_SUID_DROP, linuxrc)) |
@@ -1138,11 +1153,13 @@ int init_main(int argc UNUSED_PARAM, char **argv) | |||
1138 | } | 1153 | } |
1139 | #endif | 1154 | #endif |
1140 | 1155 | ||
1141 | /* Make the command line just say "init" - thats all, nothing else */ | 1156 | if (ENABLE_FEATURE_INIT_MODIFY_CMDLINE) { |
1142 | strncpy(argv[0], "init", strlen(argv[0])); | 1157 | /* Make the command line just say "init" - that's all, nothing else */ |
1143 | /* Wipe argv[1]-argv[N] so they don't clutter the ps listing */ | 1158 | strncpy(argv[0], "init", strlen(argv[0])); |
1144 | while (*++argv) | 1159 | /* Wipe argv[1]-argv[N] so they don't clutter the ps listing */ |
1145 | nuke_str(*argv); | 1160 | while (*++argv) |
1161 | nuke_str(*argv); | ||
1162 | } | ||
1146 | 1163 | ||
1147 | /* Set up signal handlers */ | 1164 | /* Set up signal handlers */ |
1148 | if (!DEBUG_INIT) { | 1165 | if (!DEBUG_INIT) { |