LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Killing Defunct processes (https://www.linuxquestions.org/questions/programming-9/killing-defunct-processes-912462/)

syedtamoor.h 11-08-2011 07:39 AM

Killing Defunct processes
 
Hello,

My name is Tamoor and i am doing regression testing in linux. I am trying to make a Python script which runs a number of other Python scripts located in other directories. In the script i am running a command

./test -t -1 2>&1 | tee output.log

where test is the executable, '-t -1' are arguments to test for enabling the outputs and output.log has all the outputs from the executable. The above command is executed using Popen.

The problem is that when i run the Main regression Script and execute the scripts within it, the next time when it try to execute next script, it is unable to do so. The reason is that it creats a defunct process. I dont want to kill the Parent process (Main script) but i want to kill the script (the test script executing). Can anybody let me know how to kill the defunct process since it doesn't allow the next script to run.

Please help me in this regarding.

Cedrik 11-08-2011 08:06 AM

Popen.send_signal(SIGTERM) maybe ?

http://docs.python.org/library/subpr...ess.Popen.poll

sundialsvcs 11-08-2011 08:08 AM

A parent-process in Unix/Linux should always "wait()" on its children, which is what the zombies are waiting for.

A good strategy is to arrange for the parent process just to launch children and wait for their completion, and not to participate in any of the actual work that they are doing. The parent is aware of the number of "worker" children and of their current status, but basically just sits around doing nothing.

jlinkels 11-08-2011 11:52 AM

You can't kill a defunct process because it is a zombie, and zombies cannot be killed :)

Seriously, to get rid of them, you have to kill the parent process.

In the future you must make the parent wait for the child to terminate as the other posters correctly pointed out.

jlinkels


All times are GMT -5. The time now is 09:57 AM.