aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2018-03-29 16:24:27 +0100
committerRon Yorston <rmy@pobox.com>2018-03-29 16:24:27 +0100
commitaaddde61e3009973f6e6de08ae42e1bb9accd3eb (patch)
treefa222406230b7a8129bcf6130989d85b100c7464
parent0734c043f9c0bcefa1a259d26304a1ff69cacbf0 (diff)
downloadbusybox-w32-aaddde61e3009973f6e6de08ae42e1bb9accd3eb.tar.gz
busybox-w32-aaddde61e3009973f6e6de08ae42e1bb9accd3eb.tar.bz2
busybox-w32-aaddde61e3009973f6e6de08ae42e1bb9accd3eb.zip
win32: return correct exit status from waitpid
The exit status from _cwait wasn't being correctly returned. This resulted, for example, in the exit status of xargs being incorrect. Running this: $ ls | xargs ls in a directory containing filenames with spaces should cause 'ls' to fail and 'xargs' to return an exit status of 123.
-rw-r--r--win32/process.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/win32/process.c b/win32/process.c
index de8f653c5..d6176ca23 100644
--- a/win32/process.c
+++ b/win32/process.c
@@ -12,7 +12,11 @@ int waitpid(pid_t pid, int *status, int options)
12 FALSE, pid)) != NULL ) { 12 FALSE, pid)) != NULL ) {
13 ret = _cwait(status, (intptr_t)proc, 0); 13 ret = _cwait(status, (intptr_t)proc, 0);
14 CloseHandle(proc); 14 CloseHandle(proc);
15 return ret == -1 ? -1 : pid; 15 if (ret == -1) {
16 return -1;
17 }
18 *status <<= 8;
19 return pid;
16 } 20 }
17 } 21 }
18 errno = pid < 0 ? ENOSYS : EINVAL; 22 errno = pid < 0 ? ENOSYS : EINVAL;