Skip to content

Commit 04b015a

Browse files
authored
Get Windows return code in wait() (#109)
Currently, wait() returns 0 on windows regardless of the actual return code of processes.
1 parent 2d8a8ee commit 04b015a

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

subprocess.hpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1411,7 +1411,12 @@ inline int Popen::wait() noexcept(false)
14111411
#ifdef __USING_WINDOWS__
14121412
int ret = WaitForSingleObject(process_handle_, INFINITE);
14131413

1414-
return 0;
1414+
DWORD dretcode_;
1415+
1416+
if (FALSE == GetExitCodeProcess(process_handle_, &dretcode_))
1417+
throw OSError("Failed during call to GetExitCodeProcess", 0);
1418+
1419+
return (int)dretcode_;
14151420
#else
14161421
int ret, status;
14171422
std::tie(ret, status) = util::wait_for_child_exit(pid());

0 commit comments

Comments
 (0)