diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2010-01-04 11:37:09 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2010-01-04 11:37:09 +0100 |
commit | a4899efd03d2fdaaf3f581d89a7a4844832d3fbb (patch) | |
tree | 8fab20ee4e6503866945de3bb400eadf9618b7ac | |
parent | 4168fdd8e6f5ad4d41a30a2350dbd635cc0fa6e1 (diff) | |
download | busybox-a4899efd03d2fdaaf3f581d89a7a4844832d3fbb.tar.gz |
hush: fix exitcodes of killed processes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | shell/hush.c | 6 | ||||
-rw-r--r-- | shell/hush_test/hush-misc/sig_exitcode.right | 5 | ||||
-rwxr-xr-x | shell/hush_test/hush-misc/sig_exitcode.tests | 9 |
3 files changed, 18 insertions, 2 deletions
diff --git a/shell/hush.c b/shell/hush.c index 3044024a0..25094654d 100644 --- a/shell/hush.c +++ b/shell/hush.c @@ -3896,9 +3896,7 @@ static int checkjobs(struct pipe* fg_pipe) fg_pipe->alive_cmds--; if (i == fg_pipe->num_cmds - 1) { /* last process gives overall exitstatus */ - /* Note: is WIFSIGNALED, WEXITSTATUS = sig + 128 */ rcode = WEXITSTATUS(status); - IF_HAS_KEYWORDS(if (fg_pipe->pi_inverted) rcode = !rcode;) /* bash prints killer signal's name for *last* * process in pipe (prints just newline for SIGINT). * Mimic this. Example: "sleep 5" + (^\ or kill -QUIT) @@ -3906,7 +3904,11 @@ static int checkjobs(struct pipe* fg_pipe) if (WIFSIGNALED(status)) { int sig = WTERMSIG(status); printf("%s\n", sig == SIGINT ? "" : get_signame(sig)); + /* TODO: MIPS has 128 sigs (1..128), what if sig==128 here? + * Maybe we need to use sig | 128? */ + rcode = sig + 128; } + IF_HAS_KEYWORDS(if (fg_pipe->pi_inverted) rcode = !rcode;) } } else { fg_pipe->cmds[i].is_stopped = 1; diff --git a/shell/hush_test/hush-misc/sig_exitcode.right b/shell/hush_test/hush-misc/sig_exitcode.right new file mode 100644 index 000000000..d5f000a08 --- /dev/null +++ b/shell/hush_test/hush-misc/sig_exitcode.right @@ -0,0 +1,5 @@ +KILL +137:137 +KILL +0:0 +Done diff --git a/shell/hush_test/hush-misc/sig_exitcode.tests b/shell/hush_test/hush-misc/sig_exitcode.tests new file mode 100755 index 000000000..7879dc854 --- /dev/null +++ b/shell/hush_test/hush-misc/sig_exitcode.tests @@ -0,0 +1,9 @@ +exec 2>&1 + +$THIS_SH -c 'kill -9 $$' +echo 137:$? + +! $THIS_SH -c 'kill -9 $$' +echo 0:$? + +echo Done |