st
simple terminal
git clone https://9o.is/git/st.git
commit fb107f24b6580e3f110cdaca6bb192f13f2e07ee parent 158a8a0f502f10a11bff325d961e374a6782115a Author: Roberto E. Vargas Caballero <k0ga@shike2.com> Date: Mon, 4 Aug 2014 22:07:04 +0200 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). Diffstat:
| M | st.c | | | 11 | +++++------ |
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/st.c b/st.c @@ -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