[hackers] [st] Add error message when child exits whit error || Roberto E. Vargas Caballero

From: <git_AT_suckless.org>
Date: Thu, 07 Aug 2014 08:49:15 +0200

commit ec3268961d1dc4072f6caa6f97db5436da2ff411
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
Date: Mon Aug 4 22:07:04 2014 +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).

diff --git a/st.c b/st.c
index a2703f4..45bc89d 100644
--- a/st.c
+++ b/st.c
_AT_@ -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
", 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'
", stat);
+ exit(EXIT_SUCCESS);
 }
 
 void
Received on Thu Aug 07 2014 - 08:49:15 CEST

This archive was generated by hypermail 2.3.0 : Thu Aug 07 2014 - 09:00:11 CEST