diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2017-04-07 19:13:09 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2017-04-07 19:13:09 +0200 |
commit | 42776708f21b8f7293627f88d8d5d3df00d8be1c (patch) | |
tree | e3d0af22b86aaeba888679501f1c83c346a79a99 /init | |
parent | 7121bb8023bf3e1760835bab5a16bd897ac3e878 (diff) | |
download | busybox-w32-42776708f21b8f7293627f88d8d5d3df00d8be1c.tar.gz busybox-w32-42776708f21b8f7293627f88d8d5d3df00d8be1c.tar.bz2 busybox-w32-42776708f21b8f7293627f88d8d5d3df00d8be1c.zip |
init: dont send "Sent SIGTERM to all" msg to syslog: we just TERMed it!
While at it, explain FEATURE_INIT_SYSLOG
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'init')
-rw-r--r-- | init/init.c | 40 |
1 files changed, 22 insertions, 18 deletions
diff --git a/init/init.c b/init/init.c index 833759341..4d6355167 100644 --- a/init/init.c +++ b/init/init.c | |||
@@ -73,6 +73,10 @@ | |||
73 | //config: bool "Enable init to write to syslog" | 73 | //config: bool "Enable init to write to syslog" |
74 | //config: default y | 74 | //config: default y |
75 | //config: depends on INIT || LINUXRC | 75 | //config: depends on INIT || LINUXRC |
76 | //config: help | ||
77 | //config: If selected, some init messages are sent to syslog. | ||
78 | //config: Otherwise, they are sent to VT #5 if linux virtual tty is detected | ||
79 | //config: (if not, no separate logging is done). | ||
76 | //config: | 80 | //config: |
77 | //config:config FEATURE_INIT_QUIET | 81 | //config:config FEATURE_INIT_QUIET |
78 | //config: bool "Be quiet on boot (no 'init started:' message)" | 82 | //config: bool "Be quiet on boot (no 'init started:' message)" |
@@ -212,7 +216,9 @@ struct init_action { | |||
212 | 216 | ||
213 | static struct init_action *init_action_list = NULL; | 217 | static struct init_action *init_action_list = NULL; |
214 | 218 | ||
219 | #if !ENABLE_FEATURE_INIT_SYSLOG | ||
215 | static const char *log_console = VC_5; | 220 | static const char *log_console = VC_5; |
221 | #endif | ||
216 | 222 | ||
217 | enum { | 223 | enum { |
218 | L_LOG = 0x1, | 224 | L_LOG = 0x1, |
@@ -251,17 +257,16 @@ static void message(int where, const char *fmt, ...) | |||
251 | msg[l++] = '\n'; | 257 | msg[l++] = '\n'; |
252 | msg[l] = '\0'; | 258 | msg[l] = '\0'; |
253 | #else | 259 | #else |
254 | { | 260 | msg[l++] = '\n'; |
255 | static int log_fd = -1; | 261 | msg[l] = '\0'; |
256 | 262 | if (where & L_LOG) { | |
257 | msg[l++] = '\n'; | ||
258 | msg[l] = '\0'; | ||
259 | /* Take full control of the log tty, and never close it. | 263 | /* Take full control of the log tty, and never close it. |
260 | * It's mine, all mine! Muhahahaha! */ | 264 | * It's mine, all mine! Muhahahaha! */ |
265 | static int log_fd = -1; | ||
266 | |||
261 | if (log_fd < 0) { | 267 | if (log_fd < 0) { |
262 | if (!log_console) { | 268 | log_fd = STDERR_FILENO; |
263 | log_fd = STDERR_FILENO; | 269 | if (log_console) { |
264 | } else { | ||
265 | log_fd = device_open(log_console, O_WRONLY | O_NONBLOCK | O_NOCTTY); | 270 | log_fd = device_open(log_console, O_WRONLY | O_NONBLOCK | O_NOCTTY); |
266 | if (log_fd < 0) { | 271 | if (log_fd < 0) { |
267 | bb_error_msg("can't log to %s", log_console); | 272 | bb_error_msg("can't log to %s", log_console); |
@@ -271,11 +276,9 @@ static void message(int where, const char *fmt, ...) | |||
271 | } | 276 | } |
272 | } | 277 | } |
273 | } | 278 | } |
274 | if (where & L_LOG) { | 279 | full_write(log_fd, msg, l); |
275 | full_write(log_fd, msg, l); | 280 | if (log_fd == STDERR_FILENO) |
276 | if (log_fd == STDERR_FILENO) | 281 | return; /* don't print dup messages */ |
277 | return; /* don't print dup messages */ | ||
278 | } | ||
279 | } | 282 | } |
280 | #endif | 283 | #endif |
281 | 284 | ||
@@ -325,8 +328,9 @@ static void console_init(void) | |||
325 | * if TERM is set to linux (the default) */ | 328 | * if TERM is set to linux (the default) */ |
326 | if (!s || strcmp(s, "linux") == 0) | 329 | if (!s || strcmp(s, "linux") == 0) |
327 | putenv((char*)"TERM=vt102"); | 330 | putenv((char*)"TERM=vt102"); |
328 | if (!ENABLE_FEATURE_INIT_SYSLOG) | 331 | # if !ENABLE_FEATURE_INIT_SYSLOG |
329 | log_console = NULL; | 332 | log_console = NULL; |
333 | # endif | ||
330 | } else | 334 | } else |
331 | #endif | 335 | #endif |
332 | if (!s) | 336 | if (!s) |
@@ -541,8 +545,8 @@ static pid_t run(const struct init_action *a) | |||
541 | } | 545 | } |
542 | 546 | ||
543 | /* Log the process name and args */ | 547 | /* Log the process name and args */ |
544 | message(L_LOG, "starting pid %d, tty '%s': '%s'", | 548 | message(L_LOG, "starting pid %u, tty '%s': '%s'", |
545 | getpid(), a->terminal, a->command); | 549 | (int)getpid(), a->terminal, a->command); |
546 | 550 | ||
547 | /* Now run it. The new program will take over this PID, | 551 | /* Now run it. The new program will take over this PID, |
548 | * so nothing further in init.c should be run. */ | 552 | * so nothing further in init.c should be run. */ |
@@ -757,7 +761,7 @@ static void run_shutdown_and_kill_processes(void) | |||
757 | 761 | ||
758 | /* Send signals to every process _except_ pid 1 */ | 762 | /* Send signals to every process _except_ pid 1 */ |
759 | kill(-1, SIGTERM); | 763 | kill(-1, SIGTERM); |
760 | message(L_CONSOLE | L_LOG, "Sent SIG%s to all processes", "TERM"); | 764 | message(L_CONSOLE, "Sent SIG%s to all processes", "TERM"); |
761 | sync(); | 765 | sync(); |
762 | sleep(1); | 766 | sleep(1); |
763 | 767 | ||