subprocess.Popen generates defunct

Discussion in 'Software' started by Mswed, Jul 29, 2008.

  1. Mswed

    Mswed

    Joined:
    Jul 29, 2008
    Messages:
    2
    Hi!

    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)

    FYI, it is all running on Linux.

    All suggestions are appreciated!
     
    Mswed, Jul 29, 2008
    #1
    1. Advertising

  2. Mswed

    Mswed

    Joined:
    Jul 29, 2008
    Messages:
    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 :veryprou:
     
    Mswed, Jul 29, 2008
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Pedro Sosa
    Replies:
    0
    Views:
    2,245
    Pedro Sosa
    Aug 9, 2004
  2. WCH

    mouse generates speaker noise

    WCH, Aug 17, 2005, in forum: Computer Support
    Replies:
    2
    Views:
    4,017
    Vanguard
    Aug 17, 2005
  3. FRank Benedict

    Defunct Epson Photo 780?

    FRank Benedict, Feb 1, 2004, in forum: Digital Photography
    Replies:
    1
    Views:
    339
    Mark Herring
    Feb 1, 2004
  4. Quivis
    Replies:
    0
    Views:
    456
    Quivis
    Jul 26, 2007
  5. bmt

    Python subprocess problem

    bmt, Jun 14, 2010, in forum: Software
    Replies:
    0
    Views:
    1,677
Loading...

Share This Page