subprocess.Popen generates defunct

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Mswed
    New Member
    • Jul 2008
    • 2

    subprocess.Popen generates defunct

    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.Pope n(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
  • Mswed
    New Member
    • Jul 2008
    • 2

    #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!

    Comment

    Working...