Improve wait statuses

This change has the insight that dwExitCode isn't an exit code but
rather should be used to pass the wait status. This lets us report
killing as a termination status, similar to UNIX. This change also
fixes the fact that exit(259) on Windows will break the parent due
way WIN32 is designed. We now work around that.

It turns out that NetBSD and OpenBSD, will let you have exit codes
beyond 255. This change will let you use them when it's possible.
This commit is contained in:
Justine Tunney 2023-07-30 14:26:21 -07:00
parent d9d5f45e2d
commit c8aa33e0e2
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
22 changed files with 259 additions and 75 deletions

View file

@ -28,10 +28,10 @@ __msabi extern typeof(TerminateProcess) *const __imp_TerminateProcess;
* Terminates the specified process and all of its threads.
* @note this wrapper takes care of ABI, STRACE(), and __winerr()
*/
textwindows bool32 TerminateProcess(int64_t hProcess, uint32_t uExitCode) {
textwindows bool32 TerminateProcess(int64_t hProcess, uint32_t uWaitStatus) {
bool32 ok;
ok = __imp_TerminateProcess(hProcess, uExitCode);
ok = __imp_TerminateProcess(hProcess, uWaitStatus);
if (!ok) __winerr();
NTTRACE("TerminateProcess(%ld, %u) → %hhhd% m", hProcess, uExitCode, ok);
NTTRACE("TerminateProcess(%ld, %u) → %hhhd% m", hProcess, uWaitStatus, ok);
return ok;
}