Windows: Fixed `WIFEXITED` and `WIFSIGNALED` stubs.

The `WIFEXITED` and `WIFSIGNALED` macros were incorrectly checking if
the exit code was not -1 to determine if the process exited or was
signaled. However, -1 is a valid return code on Windows, so when logic
like `CHECK(WIFEXITED(status)|| WIFSIGNALED(status))` was used, it
would end up aborting the process accidentally.

For `WIFEXITED`, we simply return `true` because all error codes on
Windows indicate the process exited (if the process instead failed to
spawn, then `os::spawn()` would return `None()` instead of an exit

For `WIFIGNALED`, we simply return `false` for similar reasons. We
assume the process did not exit due to a signal, as that is not an
expected scenario on Windows.



Branch: refs/heads/master
Commit: ca357e95f62604329dcb57076af10a86e8c25a41
Parents: 5ca0f58
Author: Akash Gupta <>
Authored: Tue Mar 6 13:11:19 2018 -0800
Committer: Andrew Schwartzmeyer <>
Committed: Tue Mar 6 13:41:49 2018 -0800

 3rdparty/stout/include/stout/windows.hpp | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/3rdparty/stout/include/stout/windows.hpp 
index 8f7817a..1bfcdf4 100644
--- a/3rdparty/stout/include/stout/windows.hpp
+++ b/3rdparty/stout/include/stout/windows.hpp
@@ -364,10 +364,13 @@ inline const char* strsignal(int signum)
 #define SIGPIPE 100
-// `os::system` returns -1 if the processor cannot be started
-// therefore any return value indicates the process has been started
+// On Windows, the exit code, unlike Linux, is simply a 32 bit unsigned integer
+// with no special encoding. Since the `status` value from `waitpid` returns a
+// 32 bit integer, we can't use it to determine if the process exited normally,
+// because all the possibilities could be valid exit codes. So, we assume that
+// if we get an exit code, the process exited normally.
 #ifndef WIFEXITED
-#define WIFEXITED(x) ((x) != -1)
+#define WIFEXITED(x) true
 #endif // WIFEXITED
 // Returns the exit status of the child.
@@ -376,8 +379,12 @@ inline const char* strsignal(int signum)
 #define WEXITSTATUS(x) static_cast<DWORD>(x)
 #endif // WEXITSTATUS
+// A signaled Windows process always exits with status code 3, but it's
+// impossible to distinguish that from a process that exits normally with
+// status code 3. Since signals aren't really used on Windows, we will
+// assume that the process is not signaled.
-#define WIFSIGNALED(x) ((x) != -1)
+#define WIFSIGNALED(x) false
 #endif // WIFSIGNALED
 // Specifies that `::waitpid` should return immediately rather than

Reply via email to