Skip to content

Commit 6476304

Browse files
lunacdhebasto
authored andcommitted
subprocess: Get Windows return code in wait()
Currently, wait() returns 0 on windows regardless of the actual return code of processes. Github-Pull: arun11299/cpp-subprocess#109 Rebased-From: 04b015a8e52ead4d8bb5f0eb486419c77e418a17
1 parent d3f511b commit 6476304

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/util/subprocess.h

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

1046-
return 0;
1046+
DWORD dretcode_;
1047+
1048+
if (FALSE == GetExitCodeProcess(process_handle_, &dretcode_))
1049+
throw OSError("Failed during call to GetExitCodeProcess", 0);
1050+
1051+
return (int)dretcode_;
10471052
#else
10481053
int ret, status;
10491054
std::tie(ret, status) = util::wait_for_child_exit(child_pid_);

0 commit comments

Comments
 (0)