summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Kleinman <samk@10gen.com>2016-01-25 12:47:23 -0500
committerSam Kleinman <samk@10gen.com>2016-01-29 13:54:39 -0500
commit187432388ef06de4c02ad5cd70b59c4634abf7a4 (patch)
tree4d1865bdf0b845d68d957dd458968c2b12f66786
parente597d3a557d62ba621f3bf67e9eede52661384c2 (diff)
downloadmongo-187432388ef06de4c02ad5cd70b59c4634abf7a4.tar.gz
SERVER-22292: make wait-for-pid operation more robust on windows
(cherry picked from commit bc065bab600d637b42c78f0622994fbd060aea01)
-rw-r--r--src/mongo/shell/shell_utils_launcher.cpp13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/mongo/shell/shell_utils_launcher.cpp b/src/mongo/shell/shell_utils_launcher.cpp
index b00a250cbdb..6aa2820bde6 100644
--- a/src/mongo/shell/shell_utils_launcher.cpp
+++ b/src/mongo/shell/shell_utils_launcher.cpp
@@ -512,10 +512,15 @@ bool wait_for_pid(ProcessId pid, bool block = true, int* exit_code = NULL) {
verify(registry._handles.count(pid));
HANDLE h = registry._handles[pid];
- if (block) {
- if (WaitForSingleObject(h, INFINITE)) {
- log() << "WaitForSingleObject failed: " << errnoWithDescription();
- }
+ // wait until the process object is signaled before getting its
+ // exit code. do this even when block is false to ensure that all
+ // file handles open in the process have been closed.
+
+ DWORD ret = WaitForSingleObject(h, (block ? INFINITE : 0));
+ if (ret == WAIT_TIMEOUT) {
+ return false;
+ } else if (ret != WAIT_OBJECT_0) {
+ log() << "wait_for_pid: WaitForSingleObject failed: " << errnoWithDescription();
}
DWORD tmp;