summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorarton <arton@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-03-22 15:05:39 +0000
committerarton <arton@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-03-22 15:05:39 +0000
commit50ff6ed8662699d28403bddd2edf0fc7db0a9b90 (patch)
treec1ca7e0dc6a7cc0eb416759a398c892b342a4fe3
parentf06ec31c54992da9eb1a69e34e69ec846aa25d2b (diff)
* win32/win32.c: wait process real termination after reading
exit code. fixes #4518 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31152 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog5
-rw-r--r--win32/win32.c8
2 files changed, 12 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 0b7fd32e96..46ef797567 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Wed Mar 23 00:12:16 2011 Tajima Akio <artonx@yahoo.co.jp>
+
+ * win32/win32.c: wait process real termination after reading
+ exit code. fixes #4518
+
Tue Mar 22 21:20:10 2011 NARUSE, Yui <naruse@ruby-lang.org>
* lib/rubygems/test_case.rb: save current dir to @current_dir
diff --git a/win32/win32.c b/win32/win32.c
index 1805fe1015..6c9da16c14 100644
--- a/win32/win32.c
+++ b/win32/win32.c
@@ -3549,6 +3549,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;
@@ -3562,7 +3563,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;
+ /* 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;
rb_pid_t pid = child->pid;
CloseChildHandle(child);
if (stat_loc) *stat_loc = exitcode << 8;