The question
Given a subprocess started in python with code similar to:
import subprocess
p = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
p.communicate()
print('Return code: {}'.format(p.returncode))
According to the official documentation, it is possible to check whether the subprocess was terminated by a signal:
A negative value -N indicates that the child was terminated by signal N (POSIX only).
But only on POSIX platforms.
Is there a way to do check if a process was terminated by a signal (do not care which one) on Windows platforms?
Background
I am running into this issue while running the tests of googletest. The break-on-failure CLI flag test fails on Windows platforms (VC14, VS2017) but works well on POSIX ones (2x Ubuntu, 2x macOS).
Manually on the command line, I get these results:
> .\googletest-break-on-failure-unittest_.exe --gtest_break_on_failure
[==========] Running 1 test from 1 test case.
[----------] Global test environment set-up.
[----------] 1 test from Foo
[ RUN ] Foo.Bar
<some path>\googletest\test\googletest-break-on-failure-unittest_.cc(52): error: Expected equality of these values:
2
3
> echo %ERRORLEVEL%
-2147483645
However, the python wrapper that calls this test receives 2147483651
(positive number).
(I just added a print before this line)
Note that these refer to the numbers 0xFFFFFFFF80000003
(negative number) and 0x80000003
(positive number) in hex and that the return code was not processed any further. (See here)
Why would the return code be changed like this?
PS: Yes, I have checked that GTEST_OS_WINDOWS
and GTEST_HAS_SEH
are true in the C++ code.