diff options
author | Mark Hammond <mhammond@apache.org> | 2009-12-02 06:38:23 +0000 |
---|---|---|
committer | Mark Hammond <mhammond@apache.org> | 2009-12-02 06:38:23 +0000 |
commit | 1902392ba62849c39fc14b2ec893e531ea9e00b3 (patch) | |
tree | 915d45a8a3e8225d816809ec2bbb36d27ffde6f8 /src/couchdb | |
parent | 095a1fbc228554e616ca5501604a4a04832d2266 (diff) |
ensure the child exit code is reported correctly to couch
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@886061 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/couchdb')
-rw-r--r-- | src/couchdb/priv/spawnkillable/couchspawnkillable_win.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/couchdb/priv/spawnkillable/couchspawnkillable_win.c b/src/couchdb/priv/spawnkillable/couchspawnkillable_win.c index f812711e..06782315 100644 --- a/src/couchdb/priv/spawnkillable/couchspawnkillable_win.c +++ b/src/couchdb/priv/spawnkillable/couchspawnkillable_win.c @@ -16,7 +16,8 @@ // * Write a line to stdout, consisting of the path to ourselves, plus // '--kill {pid}' where {pid} is the PID of the newly created process. // * Un-suspend the new process. -// * Terminate +// * Wait for the process to terminate. +// * Terminate with the child's exit-code. // Later, couch will call us with --kill and the PID, so we dutifully // terminate the specified PID. @@ -112,6 +113,7 @@ int main(int argc, char **argv) char out_buf[1024]; int rc; DWORD cbwritten; + DWORD exitcode; PROCESS_INFORMATION pi; if (argc==3 && strcmp(argv[1], "--kill")==0) { HANDLE h = OpenProcess(PROCESS_TERMINATE, 0, atoi(argv[2])); @@ -134,6 +136,10 @@ int main(int argc, char **argv) &cbwritten, NULL); // Let the child process go... ResumeThread(pi.hThread); - // and that is all - we can die... - return 0; + // Wait for the process to terminate so we can reflect the exit code + // back to couch. + WaitForSingleObject(pi.hProcess, INFINITE); + if (!GetExitCodeProcess(pi.hProcess, &exitcode)) + return 6; + return exitcode; } |