aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto E. Vargas Caballero <k0ga@shike2.com>2014-08-04 22:07:04 +0200
committerRoberto E. Vargas Caballero <k0ga@shike2.com>2014-08-04 22:07:04 +0200
commitec3268961d1dc4072f6caa6f97db5436da2ff411 (patch)
tree77b3e52b72ced49500de02e51968fbec8b6a51e8
parent769d48180747c3255653360d161c77ec2a2e8d13 (diff)
downloadst-ec3268961d1dc4072f6caa6f97db5436da2ff411.tar.gz
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.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/st.c b/st.c
index a2703f4..45bc89d 100644
--- a/st.c
+++ b/st.c
@@ -1176,16 +1176,15 @@ execsh(void) {
1176 1176
1177void 1177void
1178sigchld(int a) { 1178sigchld(int a) {
1179 int stat = 0; 1179 int stat, ret;
1180 1180
1181 if(waitpid(pid, &stat, 0) < 0) 1181 if(waitpid(pid, &stat, 0) < 0)
1182 die("Waiting for pid %hd failed: %s\n", pid, strerror(errno)); 1182 die("Waiting for pid %hd failed: %s\n", pid, strerror(errno));
1183 1183
1184 if(WIFEXITED(stat)) { 1184 ret = WIFEXITED(stat) ? WEXITSTATUS(stat) : EXIT_FAILURE;
1185 exit(WEXITSTATUS(stat)); 1185 if (ret != EXIT_SUCCESS)
1186 } else { 1186 die("child finished with error '%d'\n", stat);
1187 exit(EXIT_FAILURE); 1187 exit(EXIT_SUCCESS);
1188 }
1189} 1188}
1190 1189
1191void 1190void