aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/main.c b/src/main.c
index 9e3e551..fa17bda 100644
--- a/src/main.c
+++ b/src/main.c
@@ -177,12 +177,15 @@ static void handle_child() {
if (w == -1) {
return;
}
- if (w == pid && WIFEXITED(status)) {
+ if (w != pid) return;
+ if (WIFEXITED(status)) {
is_child = false;
detach();
- fprintf(
- stderr, "child exited with status %d\n", WEXITSTATUS(status)
- );
+ fprintf(stderr, "child exited with status %d\n", WEXITSTATUS(status));
+ } else if (WIFSIGNALED(status)) {
+ is_child = false;
+ detach();
+ fprintf(stderr, "child terminated with signal %d\n", WTERMSIG(status));
}
}