output child WEXITSTATUS/WTERMSIG on abnormal termination

dev
Lauri Tirkkonen 2018-12-11 11:43:03 +02:00 committed by Hiltjo Posthuma
parent d7bf023b2f
commit 096b125db7
1 changed files with 4 additions and 2 deletions

6
st.c
View File

@ -731,8 +731,10 @@ sigchld(int a)
if (pid != p) if (pid != p)
return; return;
if (!WIFEXITED(stat) || WEXITSTATUS(stat)) if (WIFEXITED(stat) && WEXITSTATUS(stat))
die("child finished with error '%d'\n", 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); exit(0);
} }