diff options
author | Roberto E. Vargas Caballero <k0ga@shike2.com> | 2014-08-04 22:07:04 +0200 |
---|---|---|
committer | Roberto E. Vargas Caballero <k0ga@shike2.com> | 2014-08-04 22:07:04 +0200 |
commit | ec3268961d1dc4072f6caa6f97db5436da2ff411 (patch) | |
tree | 77b3e52b72ced49500de02e51968fbec8b6a51e8 | |
parent | 769d48180747c3255653360d161c77ec2a2e8d13 (diff) | |
download | st-ec3268961d1dc4072f6caa6f97db5436da2ff411.tar.gz st-ec3268961d1dc4072f6caa6f97db5436da2ff411.tar.bz2 st-ec3268961d1dc4072f6caa6f97db5436da2ff411.zip |
Add error message when child exits whit error
Master proccess was not showing any error message when the child
died with an error, and it was very confusing for the user (for
example with incorrect -e command).
-rw-r--r-- | st.c | 11 |
1 files changed, 5 insertions, 6 deletions
@@ -1176,16 +1176,15 @@ execsh(void) { void sigchld(int a) { - int stat = 0; + int stat, ret; if(waitpid(pid, &stat, 0) < 0) die("Waiting for pid %hd failed: %s\n", pid, strerror(errno)); - if(WIFEXITED(stat)) { - exit(WEXITSTATUS(stat)); - } else { - exit(EXIT_FAILURE); - } + ret = WIFEXITED(stat) ? WEXITSTATUS(stat) : EXIT_FAILURE; + if (ret != EXIT_SUCCESS) + die("child finished with error '%d'\n", stat); + exit(EXIT_SUCCESS); } void |