aboutsummaryrefslogtreecommitdiff
path: root/libbb/xfuncs.c
diff options
context:
space:
mode:
Diffstat (limited to 'libbb/xfuncs.c')
-rw-r--r--libbb/xfuncs.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/libbb/xfuncs.c b/libbb/xfuncs.c
index 14bd62a15..7f870ac8b 100644
--- a/libbb/xfuncs.c
+++ b/libbb/xfuncs.c
@@ -192,9 +192,16 @@ int wait4pid(int pid)
192{ 192{
193 int status; 193 int status;
194 194
195 if (pid == -1 || waitpid(pid, &status, 0) == -1) return -1; 195 if (pid <= 0) {
196 if (WIFEXITED(status)) return WEXITSTATUS(status); 196 errno = ECHILD;
197 if (WIFSIGNALED(status)) return WTERMSIG(status); 197 return -1;
198 }
199 if (waitpid(pid, &status, 0) == -1)
200 return -1;
201 if (WIFEXITED(status))
202 return WEXITSTATUS(status);
203 if (WIFSIGNALED(status))
204 return WTERMSIG(status) + 10000;
198 return 0; 205 return 0;
199} 206}
200 207