londiste: avoid zombie processes with P_WAIT
authorMarko Kreen <markokr@gmail.com>
Mon, 19 Jul 2010 11:18:46 +0000 (14:18 +0300)
committerMarko Kreen <markokr@gmail.com>
Tue, 20 Jul 2010 14:41:23 +0000 (17:41 +0300)
os.spawn(P_NOWAIT) leaves zombie childs.  P_WAIT is safe
to use here, as child should daemonize itself anyway.

python/londiste/playback.py

index 69a94b40dd9e3810325e2ae37202271423512852..4225e441b76be2c1445ff39131de970790844ef9 100644 (file)
@@ -703,9 +703,12 @@ class Replicator(CascadedWorker):
             self.log.warning("Waiting for existing copy to exit")
             time.sleep(2)
 
+        # launch and wait for daemonization result
         self.log.debug("Launch args: "+repr(cmd))
-        pid = os.spawnvp(os.P_NOWAIT, script, cmd)
-        self.log.debug("Launch result: "+repr(pid))
+        res = os.spawnvp(os.P_WAIT, script, cmd)
+        self.log.debug("Launch result: "+repr(res))
+        if res != 0:
+            self.log.error("Failed to launch copy process, result=%d" % res)
 
     def sync_database_encodings(self, src_db, dst_db):
         """Make sure client_encoding is same on both side."""