Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Defunct Processes With subprocess.Popen

Reply
Thread Tools

Defunct Processes With subprocess.Popen

 
 
John Abel
Guest
Posts: n/a
 
      05-11-2005
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
 
Reply With Quote
 
 
 
 
Mike Meyer
Guest
Posts: n/a
 
      05-12-2005
John Abel <(E-Mail Removed)> 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 <(E-Mail Removed)> http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
 
Reply With Quote
 
 
 
 
John Abel
Guest
Posts: n/a
 
      05-12-2005
Mike Meyer wrote:

>John Abel <(E-Mail Removed)> 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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Avoiding defunct processes Richard Python 2 11-02-2012 03:46 PM
Daemon Server, Forking, Defunct Processes Scottman C Programming 2 09-11-2008 03:11 PM
Script to kill defunct and zombie processes Srini Vuggumudi Perl Misc 4 05-01-2004 12:14 AM
Script to kill defunct and zombie processes Srini Vuggumudi Perl Misc 0 04-29-2004 07:53 PM
<defunct> processes Gordon Beaton Java 4 11-07-2003 06:18 PM



Advertisments