Get Windows return code in wait() (#109)

Currently, wait() returns 0 on windows regardless
of the actual return code of processes.
This commit is contained in:
Haowen Liu 2025-04-22 08:02:49 -04:00 committed by GitHub
parent 2d8a8eebb0
commit 04b015a8e5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1411,7 +1411,12 @@ inline int Popen::wait() noexcept(false)
#ifdef __USING_WINDOWS__
int ret = WaitForSingleObject(process_handle_, INFINITE);
return 0;
DWORD dretcode_;
if (FALSE == GetExitCodeProcess(process_handle_, &dretcode_))
throw OSError("Failed during call to GetExitCodeProcess", 0);
return (int)dretcode_;
#else
int ret, status;
std::tie(ret, status) = util::wait_for_child_exit(pid());