diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2007-04-14 11:16:29 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2007-04-14 11:16:29 +0000 |
commit | 8a28e620ce6017fd184c26a7ce25f5e167a90fe7 (patch) | |
tree | b1c51ade423d7670655c8e2d02acbae4d58276c9 /shell/hush.c | |
parent | bf3561fd15cff3fbfe6f67d134c23149ed35f493 (diff) | |
download | busybox-w32-8a28e620ce6017fd184c26a7ce25f5e167a90fe7.tar.gz busybox-w32-8a28e620ce6017fd184c26a7ce25f5e167a90fe7.tar.bz2 busybox-w32-8a28e620ce6017fd184c26a7ce25f5e167a90fe7.zip |
lash: recognize and use NOFORK applets
lash,hush: fix kill buglet (didn't properly recognize ESRCH)
Diffstat (limited to 'shell/hush.c')
-rw-r--r-- | shell/hush.c | 37 |
1 files changed, 16 insertions, 21 deletions
diff --git a/shell/hush.c b/shell/hush.c index 9362e5916..0b5e2a5de 100644 --- a/shell/hush.c +++ b/shell/hush.c | |||
@@ -547,7 +547,7 @@ static int builtin_export(struct child_prog *child) | |||
547 | static int builtin_fg_bg(struct child_prog *child) | 547 | static int builtin_fg_bg(struct child_prog *child) |
548 | { | 548 | { |
549 | int i, jobnum; | 549 | int i, jobnum; |
550 | struct pipe *pi = NULL; | 550 | struct pipe *pi; |
551 | 551 | ||
552 | if (!interactive) | 552 | if (!interactive) |
553 | return EXIT_FAILURE; | 553 | return EXIT_FAILURE; |
@@ -555,29 +555,24 @@ static int builtin_fg_bg(struct child_prog *child) | |||
555 | if (!child->argv[1]) { | 555 | if (!child->argv[1]) { |
556 | for (pi = job_list; pi; pi = pi->next) { | 556 | for (pi = job_list; pi; pi = pi->next) { |
557 | if (pi->jobid == last_jobid) { | 557 | if (pi->jobid == last_jobid) { |
558 | break; | 558 | goto found; |
559 | } | ||
560 | } | ||
561 | if (!pi) { | ||
562 | bb_error_msg("%s: no current job", child->argv[0]); | ||
563 | return EXIT_FAILURE; | ||
564 | } | ||
565 | } else { | ||
566 | if (sscanf(child->argv[1], "%%%d", &jobnum) != 1) { | ||
567 | bb_error_msg("%s: bad argument '%s'", child->argv[0], child->argv[1]); | ||
568 | return EXIT_FAILURE; | ||
569 | } | ||
570 | for (pi = job_list; pi; pi = pi->next) { | ||
571 | if (pi->jobid == jobnum) { | ||
572 | break; | ||
573 | } | 559 | } |
574 | } | 560 | } |
575 | if (!pi) { | 561 | bb_error_msg("%s: no current job", child->argv[0]); |
576 | bb_error_msg("%s: %d: no such job", child->argv[0], jobnum); | 562 | return EXIT_FAILURE; |
577 | return EXIT_FAILURE; | 563 | } |
564 | if (sscanf(child->argv[1], "%%%d", &jobnum) != 1) { | ||
565 | bb_error_msg("%s: bad argument '%s'", child->argv[0], child->argv[1]); | ||
566 | return EXIT_FAILURE; | ||
567 | } | ||
568 | for (pi = job_list; pi; pi = pi->next) { | ||
569 | if (pi->jobid == jobnum) { | ||
570 | goto found; | ||
578 | } | 571 | } |
579 | } | 572 | } |
580 | 573 | bb_error_msg("%s: %d: no such job", child->argv[0], jobnum); | |
574 | return EXIT_FAILURE; | ||
575 | found: | ||
581 | if (*child->argv[0] == 'f') { | 576 | if (*child->argv[0] == 'f') { |
582 | /* Put the job into the foreground. */ | 577 | /* Put the job into the foreground. */ |
583 | tcsetpgrp(shell_terminal, pi->pgrp); | 578 | tcsetpgrp(shell_terminal, pi->pgrp); |
@@ -589,7 +584,7 @@ static int builtin_fg_bg(struct child_prog *child) | |||
589 | 584 | ||
590 | i = kill(- pi->pgrp, SIGCONT); | 585 | i = kill(- pi->pgrp, SIGCONT); |
591 | if (i < 0) { | 586 | if (i < 0) { |
592 | if (i == ESRCH) { | 587 | if (errno == ESRCH) { |
593 | remove_bg_job(pi); | 588 | remove_bg_job(pi); |
594 | } else { | 589 | } else { |
595 | bb_perror_msg("kill (SIGCONT)"); | 590 | bb_perror_msg("kill (SIGCONT)"); |