By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,761 Members | 1,108 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,761 IT Pros & Developers. It's quick & easy.

subprocess.Popen generates defunct

P: 2
Hi all!

I hope someone can help me out here!

I'm running a GUI in python which is able to launch a separate python process that will run forever. In rare cases I will want to kill the launched process. Every time I do so, I end up with the process as defunct. Can anybody help me clean it up in a nice way?

My code snippets:
#Launching a separate process (no communication in between the process needed)
# When closing the GUI, the launched program should not be killed.

command = ['test.py',' -c ',config]
process = subprocess.Popen(command, preexec_fn = os.setsid)

On request from GUI I do the following:
os.kill(process.pid,9)

It is all running on Linux.

Anyone knows why I'm getting the defunc problem?

-Maria
Jul 29 '08 #1
Share this Question
Share on Google+
1 Reply

P: 2
Ok, found what was missing.

Tips for anyone encountering similar problems, after the kill add a line with
os.wait()

Have a great day everybody!
Jul 29 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.