]> SALOME platform Git repositories - modules/kernel.git/commitdiff
Salome HOME
CCAR: server.py modification to store pid process in pidict only if they
authorcaremoli <caremoli>
Tue, 27 Jan 2009 09:01:32 +0000 (09:01 +0000)
committercaremoli <caremoli>
Tue, 27 Jan 2009 09:01:32 +0000 (09:01 +0000)
      are still alive after exec

bin/server.py

index ac2690aba79900a2c59cdb6c1b666a830a2a0748..a5588c6b6acb56ba4a1f7c16ae3ae58345acf84e 100755 (executable)
@@ -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