Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Python (http://www.velocityreviews.com/forums/f43-python.html)
-   -   Defunct Processes With subprocess.Popen (http://www.velocityreviews.com/forums/t344785-defunct-processes-with-subprocess-popen.html)

John Abel 05-11-2005 08:29 AM

Defunct Processes With subprocess.Popen
 
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

Mike Meyer 05-12-2005 04:39 AM

Re: Defunct Processes With subprocess.Popen
 
John Abel <jabel@plus.net> 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 <mwm@mired.org> http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.

John Abel 05-12-2005 07:53 AM

Re: Defunct Processes With subprocess.Popen
 
Mike Meyer wrote:

>John Abel <jabel@plus.net> 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


All times are GMT. The time now is 08:28 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.