LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 11-08-2011, 07:39 AM   #1
syedtamoor.h
LQ Newbie
 
Registered: Nov 2011
Posts: 1

Rep: Reputation: Disabled
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.
 
Old 11-08-2011, 08:06 AM   #2
Cedrik
Senior Member
 
Registered: Jul 2004
Distribution: Slackware
Posts: 2,140

Rep: Reputation: 244Reputation: 244Reputation: 244
Popen.send_signal(SIGTERM) maybe ?

http://docs.python.org/library/subpr...ess.Popen.poll
 
Old 11-08-2011, 08:08 AM   #3
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,610
Blog Entries: 4

Rep: Reputation: 3905Reputation: 3905Reputation: 3905Reputation: 3905Reputation: 3905Reputation: 3905Reputation: 3905Reputation: 3905Reputation: 3905Reputation: 3905Reputation: 3905
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.
 
Old 11-08-2011, 11:52 AM   #4
jlinkels
LQ Guru
 
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195

Rep: Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043
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
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
defunct processes tajamari Linux - Software 5 06-26-2008 12:24 AM
killev script not killing defunct evolution ender42 Ubuntu 1 05-06-2006 10:00 AM
defunct processes in cron bujecas Debian 1 02-07-2006 01:59 PM
Apache: libhttpd.ep -> hundreds of defunct, killing my server praefex Linux - General 0 02-10-2004 02:14 PM
processes showing defunct jpbarto Linux - Software 2 11-05-2003 10:15 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:27 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration