From aaddde61e3009973f6e6de08ae42e1bb9accd3eb Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Thu, 29 Mar 2018 16:24:27 +0100 Subject: 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. --- win32/process.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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) FALSE, pid)) != NULL ) { ret = _cwait(status, (intptr_t)proc, 0); CloseHandle(proc); - return ret == -1 ? -1 : pid; + if (ret == -1) { + return -1; + } + *status <<= 8; + return pid; } } errno = pid < 0 ? ENOSYS : EINVAL; -- cgit v1.2.3-55-g6feb