summaryrefslogtreecommitdiffstats
path: root/otherlibs/win32unix/winwait.c
diff options
context:
space:
mode:
Diffstat (limited to 'otherlibs/win32unix/winwait.c')
-rw-r--r--otherlibs/win32unix/winwait.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/otherlibs/win32unix/winwait.c b/otherlibs/win32unix/winwait.c
index bac345b40..873c84a5d 100644
--- a/otherlibs/win32unix/winwait.c
+++ b/otherlibs/win32unix/winwait.c
@@ -43,14 +43,16 @@ CAMLprim value win_waitpid(value vflags, value vpid_req)
int flags;
DWORD status, retcode;
HANDLE pid_req = (HANDLE) Long_val(vpid_req);
+ DWORD errcode = 0;
flags = convert_flag_list(vflags, wait_flag_table);
if ((flags & CAML_WNOHANG) == 0) {
enter_blocking_section();
retcode = WaitForSingleObject(pid_req, INFINITE);
+ if (retcode == WAIT_FAILED) errcode = GetLastError();
leave_blocking_section();
- if (retcode == WAIT_FAILED) {
- win32_maperr(GetLastError());
+ if (errcode) {
+ win32_maperr(errcode);
uerror("waitpid", Nothing);
}
}