diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2007-12-25 16:08:53 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2007-12-25 16:08:53 +0000 |
commit | 5adfa44101ff03299775af84d30a04d88aa0bb81 (patch) | |
tree | 1e372701798199df6acaa693cf1ac766ecc5b798 | |
parent | 1d61416b5a66c1123443f00fdf8ba452290a72aa (diff) | |
download | busybox-w32-5adfa44101ff03299775af84d30a04d88aa0bb81.tar.gz busybox-w32-5adfa44101ff03299775af84d30a04d88aa0bb81.tar.bz2 busybox-w32-5adfa44101ff03299775af84d30a04d88aa0bb81.zip |
init: sometimes, #ifdefs are cleaner.
-rw-r--r-- | init/init.c | 35 |
1 files changed, 13 insertions, 22 deletions
diff --git a/init/init.c b/init/init.c index f2e5d9d43..83678c1c3 100644 --- a/init/init.c +++ b/init/init.c | |||
@@ -326,14 +326,9 @@ static pid_t run(const struct init_action *a) | |||
326 | open_stdio_to_tty(a->terminal, 1 /* - exit if open fails*/); | 326 | open_stdio_to_tty(a->terminal, 1 /* - exit if open fails*/); |
327 | 327 | ||
328 | #ifdef BUT_RUN_ACTIONS_ALREADY_DOES_WAITING | 328 | #ifdef BUT_RUN_ACTIONS_ALREADY_DOES_WAITING |
329 | # define BRAADS 1 | ||
330 | #else | ||
331 | # define BRAADS 0 | ||
332 | #endif | ||
333 | /* If the init Action requires us to wait, then force the | 329 | /* If the init Action requires us to wait, then force the |
334 | * supplied terminal to be the controlling tty. */ | 330 | * supplied terminal to be the controlling tty. */ |
335 | if (BRAADS && a->action & (SYSINIT | WAIT | CTRLALTDEL | SHUTDOWN | RESTART)) { | 331 | if (a->action & (SYSINIT | WAIT | CTRLALTDEL | SHUTDOWN | RESTART)) { |
336 | |||
337 | /* Now fork off another process to just hang around */ | 332 | /* Now fork off another process to just hang around */ |
338 | pid = fork(); | 333 | pid = fork(); |
339 | if (pid < 0) { | 334 | if (pid < 0) { |
@@ -370,6 +365,7 @@ static pid_t run(const struct init_action *a) | |||
370 | 365 | ||
371 | /* Child - fall though to actually execute things */ | 366 | /* Child - fall though to actually execute things */ |
372 | } | 367 | } |
368 | #endif | ||
373 | 369 | ||
374 | /* See if any special /bin/sh requiring characters are present */ | 370 | /* See if any special /bin/sh requiring characters are present */ |
375 | if (strpbrk(a->command, "~`!$^&*()=|\\{}[];\"'<>?") != NULL) { | 371 | if (strpbrk(a->command, "~`!$^&*()=|\\{}[];\"'<>?") != NULL) { |
@@ -403,23 +399,18 @@ static pid_t run(const struct init_action *a) | |||
403 | ++cmdpath; | 399 | ++cmdpath; |
404 | 400 | ||
405 | #ifdef WHY_WE_DO_THIS_SHELL_MUST_HANDLE_THIS_ITSELF | 401 | #ifdef WHY_WE_DO_THIS_SHELL_MUST_HANDLE_THIS_ITSELF |
406 | # define WWDTSMHTI 1 | 402 | /* find the last component in the command pathname */ |
407 | #else | 403 | s = bb_get_last_path_component_nostrip(cmdpath); |
408 | # define WWDTSMHTI 0 | 404 | /* make a new argv[0] */ |
409 | #endif | 405 | cmd[0] = malloc(strlen(s) + 2); |
410 | if (WWDTSMHTI) { | 406 | if (cmd[0] == NULL) { |
411 | /* find the last component in the command pathname */ | 407 | message(L_LOG | L_CONSOLE, bb_msg_memory_exhausted); |
412 | s = bb_get_last_path_component_nostrip(cmdpath); | 408 | cmd[0] = cmdpath; |
413 | /* make a new argv[0] */ | 409 | } else { |
414 | cmd[0] = malloc(strlen(s) + 2); | 410 | cmd[0][0] = '-'; |
415 | if (cmd[0] == NULL) { | 411 | strcpy(cmd[0] + 1, s); |
416 | message(L_LOG | L_CONSOLE, bb_msg_memory_exhausted); | ||
417 | cmd[0] = cmdpath; | ||
418 | } else { | ||
419 | cmd[0][0] = '-'; | ||
420 | strcpy(cmd[0] + 1, s); | ||
421 | } | ||
422 | } | 412 | } |
413 | #endif | ||
423 | 414 | ||
424 | /* Establish this process as session leader and | 415 | /* Establish this process as session leader and |
425 | * _attempt_ to make stdin a controlling tty. | 416 | * _attempt_ to make stdin a controlling tty. |