Re: Defunct when using subprocess.Popen

Discussion in 'Python' started by Gabriel Genellina, Jul 30, 2008.

  1. En Tue, 29 Jul 2008 10:04:46 -0300, Gordon Maria
    <> escribi�:

    > 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?
    >
    > On request from GUI I do the following:
    > os.kill(process.pid,9)
    >
    > FYI, it is all running on Linux.


    You should call os.waitpid() after killing the child process, to let the
    OS free the resources allocated to it.

    --
    Gabriel Genellina
    Gabriel Genellina, Jul 30, 2008
    #1
    1. Advertising

  2. On Wed, 30 Jul 2008 01:56:28 -0300, Gabriel Genellina wrote:

    > You should call os.waitpid() after killing the child process, to let the
    > OS free the resources allocated to it.
    >


    The subprocess.Popen object supports a 'wait' method directly.
    Bruce Frederiksen, Jul 30, 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. John Abel
    Replies:
    2
    Views:
    3,290
    John Abel
    May 12, 2005
  2. William Hudspeth
    Replies:
    2
    Views:
    295
    Fabio FZero
    Mar 15, 2007
  3. William Hudspeth
    Replies:
    1
    Views:
    396
    Sion Arrowsmith
    Mar 16, 2007
  4. Replies:
    2
    Views:
    583
  5. Tim Golden
    Replies:
    0
    Views:
    456
    Tim Golden
    Oct 7, 2007
Loading...

Share This Page