From e651f316420d4366605cd5614b4b6ede46ea451a Mon Sep 17 00:00:00 2001 From: Lauri Tirkkonen Date: Tue, 11 Dec 2018 11:43:03 +0200 Subject: [PATCH] output child WEXITSTATUS/WTERMSIG on abnormal termination --- st.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/st.c b/st.c index bc761ba..5a2a898 100644 --- a/st.c +++ b/st.c @@ -738,8 +738,10 @@ sigchld(int a) if (pid != p) return; - if (!WIFEXITED(stat) || WEXITSTATUS(stat)) - die("child finished with error '%d'\n", stat); + if (WIFEXITED(stat) && WEXITSTATUS(stat)) + die("child exited with status %d\n", WEXITSTATUS(stat)); + else if (WIFSIGNALED(stat)) + die("child terminated due to signal %d\n", WTERMSIG(stat)); exit(0); }