summaryrefslogtreecommitdiff
path: root/init/init.c
diff options
context:
space:
mode:
authorBernhard Reutner-Fischer <rep.dot.nop@gmail.com>2006-05-29 12:54:16 +0000
committerBernhard Reutner-Fischer <rep.dot.nop@gmail.com>2006-05-29 12:54:16 +0000
commit0da069d3826568101560920bc2ca1796b1392630 (patch)
tree389334b0f92826239cd37087fcada43ef794e19d /init/init.c
parentbbc225e13d0b4388a095c98c86caff6dd675962b (diff)
downloadbusybox-w32-0da069d3826568101560920bc2ca1796b1392630.tar.gz
busybox-w32-0da069d3826568101560920bc2ca1796b1392630.tar.bz2
busybox-w32-0da069d3826568101560920bc2ca1796b1392630.zip
- move common code into new open_new_terminal() function;
text data bss dec hex filename 864434 10244 645892 1520570 1733ba busybox_old 864386 10244 645892 1520522 17338a busybox_unstripped add/remove: 1/0 grow/shrink: 0/2 up/down: 92/-143 (-51) function old new delta open_new_terminal - 92 +92 exec_signal 345 276 -69 run 1527 1453 -74 Again, 48 != 51 so let's trust the former..
Diffstat (limited to 'init/init.c')
-rw-r--r--init/init.c50
1 files changed, 27 insertions, 23 deletions
diff --git a/init/init.c b/init/init.c
index ec3c4d7cf..d800480ee 100644
--- a/init/init.c
+++ b/init/init.c
@@ -386,6 +386,23 @@ static void fixup_argv(int argc, char **argv, char *new_argv0)
386 } 386 }
387} 387}
388 388
389/* Open the new terminal device */
390static void open_new_terminal(const char *device, char fail) {
391 struct stat sb;
392
393 if ((device_open(device, O_RDWR)) < 0) {
394 if (stat(device, &sb) != 0) {
395 message(LOG | CONSOLE, "device '%s' does not exist.", device);
396 } else {
397 message(LOG | CONSOLE, "Bummer, can't open %s", device);
398 }
399 if (fail)
400 _exit(1);
401 /* else */
402 halt_signal(SIGUSR1);
403 }
404}
405
389static pid_t run(const struct init_action *a) 406static pid_t run(const struct init_action *a)
390{ 407{
391 int i, junk; 408 int i, junk;
@@ -405,7 +422,6 @@ static pid_t run(const struct init_action *a)
405 sigprocmask(SIG_BLOCK, &nmask, &omask); 422 sigprocmask(SIG_BLOCK, &nmask, &omask);
406 423
407 if ((pid = fork()) == 0) { 424 if ((pid = fork()) == 0) {
408 struct stat sb;
409 425
410 /* Clean up */ 426 /* Clean up */
411 close(0); 427 close(0);
@@ -429,14 +445,7 @@ static pid_t run(const struct init_action *a)
429 setsid(); 445 setsid();
430 446
431 /* Open the new terminal device */ 447 /* Open the new terminal device */
432 if ((device_open(a->terminal, O_RDWR)) < 0) { 448 open_new_terminal(a->terminal, 1);
433 if (stat(a->terminal, &sb) != 0) {
434 message(LOG | CONSOLE, "device '%s' does not exist.", a->terminal);
435 } else {
436 message(LOG | CONSOLE, "Bummer, can't open %s", a->terminal);
437 }
438 _exit(1);
439 }
440 449
441 /* Make sure the terminal will act fairly normal for us */ 450 /* Make sure the terminal will act fairly normal for us */
442 set_term(0); 451 set_term(0);
@@ -575,12 +584,15 @@ static pid_t run(const struct init_action *a)
575 getpid(), a->terminal, cmdpath); 584 getpid(), a->terminal, cmdpath);
576 585
577#if defined CONFIG_FEATURE_INIT_COREDUMPS 586#if defined CONFIG_FEATURE_INIT_COREDUMPS
578 if (stat(CORE_ENABLE_FLAG_FILE, &sb) == 0) { 587 {
579 struct rlimit limit; 588 struct stat sb;
589 if (stat(CORE_ENABLE_FLAG_FILE, &sb) == 0) {
590 struct rlimit limit;
580 591
581 limit.rlim_cur = RLIM_INFINITY; 592 limit.rlim_cur = RLIM_INFINITY;
582 limit.rlim_max = RLIM_INFINITY; 593 limit.rlim_max = RLIM_INFINITY;
583 setrlimit(RLIMIT_CORE, &limit); 594 setrlimit(RLIMIT_CORE, &limit);
595 }
584 } 596 }
585#endif 597#endif
586 598
@@ -729,15 +741,7 @@ static void exec_signal(int sig ATTRIBUTE_UNUSED)
729 close(2); 741 close(2);
730 742
731 /* Open the new terminal device */ 743 /* Open the new terminal device */
732 if ((device_open(a->terminal, O_RDWR)) < 0) { 744 open_new_terminal(a->terminal, 0);
733 struct stat sb;
734 if (stat(a->terminal, &sb) != 0) {
735 message(LOG | CONSOLE, "device '%s' does not exist.", a->terminal);
736 } else {
737 message(LOG | CONSOLE, "Bummer, can't open %s", a->terminal);
738 }
739 halt_signal(SIGUSR1);
740 }
741 745
742 /* Make sure the terminal will act fairly normal for us */ 746 /* Make sure the terminal will act fairly normal for us */
743 set_term(0); 747 set_term(0);