← Commit list

a4899efd0

Denys Vlasenko
Denys Vlasenko
2010-01-04
FAILED Duration: 28s

Subject

hush: fix exitcodes of killed processes

Binary

No binary (build failed)

Architecture & Compiler Flags

Architecture: x86_64-linux-gnu Compiler: gcc (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0

—

Build Log

(log yok)

Commit Diff GitHub →

shell/hush.c+4 -2
@@ -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;
shell/hush_test/hush-misc/sig_exitcode.right+5 -0
@@ -0,0 +1,5 @@
+KILL
+137:137
+KILL
+0:0
+Done
shell/hush_test/hush-misc/sig_exitcode.tests+9 -0
@@ -0,0 +1,9 @@
+exec 2>&1
+
+$THIS_SH -c 'kill -9 $$'
+echo 137:$?
+
+! $THIS_SH -c 'kill -9 $$'
+echo 0:$?
+
+echo Done