]> granicus.if.org Git - php/commitdiff
Capture Microsoft-defined HRESULT exit codes exit codes
authorDylan K. Taylor <odigiman@gmail.com>
Tue, 23 Feb 2021 21:34:51 +0000 (22:34 +0100)
committerChristoph M. Becker <cmbecker69@gmx.de>
Thu, 25 Feb 2021 11:01:04 +0000 (12:01 +0100)
The lack of such a check leads to false-passes of tests on Windows
which expect no output, but produce a segfault or similar issue. I
discovered this a while ago due to bad tests in an extension I maintain.

Closes GH-6722.

run-tests.php

index c68982889a7fa4c4a0201a3632ce9aa513f79960..19b7f5cb4015d00823d154fd0b256389c2d8d6cc 100755 (executable)
@@ -1273,6 +1273,9 @@ function system_with_timeout($commandline, $env = null, $stdin = null, $captureS
     }
     if ($stat["exitcode"] > 128 && $stat["exitcode"] < 160) {
         $data .= "\nTermsig=" . ($stat["exitcode"] - 128) . "\n";
+    } else if (defined('PHP_WINDOWS_VERSION_MAJOR') && (($stat["exitcode"] >> 28) & 0b1111) === 0b1100) {
+        // https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-erref/87fba13e-bf06-450e-83b1-9241dc81e781
+        $data .= "\nTermsig=" . $stat["exitcode"] . "\n";
     }
 
     proc_close($proc);