diff options
author | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-05-29 22:48:07 +0000 |
---|---|---|
committer | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-05-29 22:48:07 +0000 |
commit | cca6b1d3769835b70670c208bf18365d27812738 (patch) | |
tree | 2a7f1ca8f203ae895438418187e0a53141e27cee /win32 | |
parent | 8cd1c4ddab456bd5084d9272bb335e11a3651232 (diff) |
merges r31152 and r31154 from trunk into ruby_1_9_2.
--
* win32/win32.c: wait process real termination after reading
exit code. fixes #4518
--
* win32/win32.c: fix r31152 (dup line)
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_2@31789 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'win32')
-rw-r--r-- | win32/win32.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/win32/win32.c b/win32/win32.c index 4d647f9d8e..55e8c1237d 100644 --- a/win32/win32.c +++ b/win32/win32.c @@ -3559,6 +3559,7 @@ poll_child_status(struct ChildRecord *child, int *stat_loc) if (!GetExitCodeProcess(child->hProcess, &exitcode)) { /* If an error occured, return immediatly. */ + error_exit: err = GetLastError(); if (err == ERROR_INVALID_PARAMETER) errno = ECHILD; @@ -3572,8 +3573,12 @@ poll_child_status(struct ChildRecord *child, int *stat_loc) return -1; } if (exitcode != STILL_ACTIVE) { - /* If already died, return immediatly. */ - rb_pid_t pid = child->pid; + rb_pid_t pid; + /* If already died, wait process's real termination. */ + if (rb_w32_wait_events_blocking(&child->hProcess, 1, INFINITE) != WAIT_OBJECT_0) { + goto error_exit; + } + pid = child->pid; CloseChildHandle(child); if (stat_loc) *stat_loc = exitcode << 8; return pid; |