couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mhamm...@apache.org
Subject svn commit: r886061 - /couchdb/trunk/src/couchdb/priv/spawnkillable/couchspawnkillable_win.c
Date Wed, 02 Dec 2009 06:38:23 GMT
Author: mhammond
Date: Wed Dec  2 06:38:23 2009
New Revision: 886061

URL: http://svn.apache.org/viewvc?rev=886061&view=rev
Log:
ensure the child exit code is reported correctly to couch

Modified:
    couchdb/trunk/src/couchdb/priv/spawnkillable/couchspawnkillable_win.c

Modified: couchdb/trunk/src/couchdb/priv/spawnkillable/couchspawnkillable_win.c
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/priv/spawnkillable/couchspawnkillable_win.c?rev=886061&r1=886060&r2=886061&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/priv/spawnkillable/couchspawnkillable_win.c (original)
+++ couchdb/trunk/src/couchdb/priv/spawnkillable/couchspawnkillable_win.c Wed Dec  2 06:38:23
2009
@@ -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 @@
     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 @@
               &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;
 }



Mime
View raw message