From 7ddd364a83b7a8f3ab6720f805df6b62aee6ea88 Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Tue, 18 Jul 2023 01:33:39 +0200 Subject: process: preserve the exit code more If the process is killed by a signal, preserve the exit code as it would be reported by $?. --- src/process.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/process.c b/src/process.c index ee387bb..3fc866f 100644 --- a/src/process.c +++ b/src/process.c @@ -42,6 +42,8 @@ static int wait_for_child(pid_t pid, int *ec) if (WIFEXITED(status)) *ec = WEXITSTATUS(status); + else if (WIFSIGNALED(status)) + *ec = status; /* Same as $?. */ else *ec = -1; -- cgit v1.2.3