Closed hsuyeep closed 9 years ago
Solved. The problem was that Popen() needed to create a process group, so that a SIGTERM to the top level process would propagate to the other children as well. This was achieved by passing an extra parameter to Popen(preexec_fn=os.setsid), making the calling process the session leader. The kill then becomes os.killpg(pid, signal.SIGTERM). Finally, the parent had to call wait(), else zombie processes were being generated.
cmdclient uses the subprocess module to run the commands requested by acontrol. If the called subprocess fails, an exception is raised, but currently does not clear the state in cmdClient. acontrol then starts a fresh observation by giving a STOP command to all cmdclients, leading to cmdClient crashing when it tries to kill the non-existent processes.