From 5c008e9f6b3b6ada064d358e0a3085b271f277f5 Mon Sep 17 00:00:00 2001 From: caremoli Date: Tue, 27 Jan 2009 09:01:32 +0000 Subject: [PATCH] CCAR: server.py modification to store pid process in pidict only if they are still alive after exec --- bin/server.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/bin/server.py b/bin/server.py index ac2690aba..a5588c6b6 100755 --- a/bin/server.py +++ b/bin/server.py @@ -63,7 +63,9 @@ class Server: else: #pid = os.spawnvp(os.P_NOWAIT, command[0], command) pid=self.daemonize(command) - process_id[pid]=self.CMD + if pid is not None: + #store process pid if it really exists + process_id[pid]=self.CMD self.PID = pid return pid @@ -84,7 +86,14 @@ class Server: os.waitpid(pid,0) #remove zombie os.close(c2pread) # return : first parent - return int(data) + childpid=int(data) + if childpid==-1: + return None + try: + os.kill(childpid,0) + return childpid + except: + return None #first child # decouple from parent environment -- 2.39.2