Defunct Processes With subprocess.Popen

Discussion in 'Python' started by John Abel, May 11, 2005.

  1. John Abel

    John Abel Guest

    Hi!

    I'm currently writing a script which launches external programs, but it
    keeps leaving zombie/defunct processes behind, until I kill the
    launching script, which is a bit of a pain, as it's supposed to be a
    daemon. The code I'm using is:

    newPid = subprocess.Popen( cmdLine[ 1: ], executable=cmdLine[ 0 ],
    close_fds=True ).pid

    I've tried calling it using the shell=True flag, but that leaves a
    zombie for the sh, instead. I'm not interested in any output, the only
    thing I need returning, is the pid of the new process. I've tried using
    spawn*, with the same results. Does anyone have any ideas?

    Thanks.

    J
     
    John Abel, May 11, 2005
    #1
    1. Advertising

  2. John Abel

    Mike Meyer Guest

    John Abel <> writes:

    > Hi!
    >
    > I'm currently writing a script which launches external programs, but
    > it keeps leaving zombie/defunct processes behind, until I kill the
    > launching script, which is a bit of a pain, as it's supposed to be a
    > daemon. The code I'm using is:
    >
    > newPid = subprocess.Popen( cmdLine[ 1: ], executable=cmdLine[ 0 ],
    > close_fds=True ).pid
    >
    > I've tried calling it using the shell=True flag, but that leaves a
    > zombie for the sh, instead. I'm not interested in any output, the
    > only thing I need returning, is the pid of the new process. I've
    > tried using spawn*, with the same results. Does anyone have any ideas?


    The processes are hanging around in a zombie state so the parent (or
    someone) can get their exit status.

    Try calling os.wait() until it returns the exit status for all the
    processes you've started.

    <mike
    --
    Mike Meyer <> http://www.mired.org/home/mwm/
    Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
     
    Mike Meyer, May 12, 2005
    #2
    1. Advertising

  3. John Abel

    John Abel Guest

    Mike Meyer wrote:

    >John Abel <> writes:
    >
    >
    >
    >>Hi!
    >>
    >>I'm currently writing a script which launches external programs, but
    >>it keeps leaving zombie/defunct processes behind, until I kill the
    >>launching script, which is a bit of a pain, as it's supposed to be a
    >>daemon. The code I'm using is:
    >>
    >>newPid = subprocess.Popen( cmdLine[ 1: ], executable=cmdLine[ 0 ],
    >>close_fds=True ).pid
    >>
    >>I've tried calling it using the shell=True flag, but that leaves a
    >>zombie for the sh, instead. I'm not interested in any output, the
    >>only thing I need returning, is the pid of the new process. I've
    >>tried using spawn*, with the same results. Does anyone have any ideas?
    >>
    >>

    >
    >The processes are hanging around in a zombie state so the parent (or
    >someone) can get their exit status.
    >
    >Try calling os.wait() until it returns the exit status for all the
    >processes you've started.
    >
    > <mike
    >
    >

    Ahh, OK. Thanks for that. Works now.

    J
     
    John Abel, May 12, 2005
    #3
    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. Gordon Beaton

    <defunct> processes

    Gordon Beaton, Oct 27, 2003, in forum: Java
    Replies:
    4
    Views:
    10,937
    Andrew
    Nov 7, 2003
  2. Gabriel Genellina

    Re: Defunct when using subprocess.Popen

    Gabriel Genellina, Jul 30, 2008, in forum: Python
    Replies:
    1
    Views:
    553
    Bruce Frederiksen
    Jul 30, 2008
  3. Scottman

    Daemon Server, Forking, Defunct Processes

    Scottman, Sep 11, 2008, in forum: C Programming
    Replies:
    2
    Views:
    993
    CBFalconer
    Sep 11, 2008
  4. Srini Vuggumudi

    Script to kill defunct and zombie processes

    Srini Vuggumudi, Apr 29, 2004, in forum: Perl Misc
    Replies:
    4
    Views:
    674
    Chris Mattern
    May 1, 2004
  5. Srini Vuggumudi

    Script to kill defunct and zombie processes

    Srini Vuggumudi, Apr 29, 2004, in forum: Perl Misc
    Replies:
    0
    Views:
    177
    Srini Vuggumudi
    Apr 29, 2004
Loading...

Share This Page