473,442 Members | 1,934 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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
Jul 19 '05 #1
2 10001
John Abel <ja***@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 <mw*@mired.org> http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
Jul 19 '05 #2
Mike Meyer wrote:
John Abel <ja***@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
Jul 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: Eric_Dexter | last post by:
I am trying to modify a programming example and I am coming up with two problems... first is that I can't seem to pass along the arguments to the external command (I have been able to do that with...
9
by: Phoe6 | last post by:
Hi all, Consider this scenario, where in I need to use subprocess to execute a command like 'ping 127.0.0.1' which will have a continuous non- terminating output in Linux. # code # This...
7
by: skunkwerk | last post by:
Hi, i'm trying to call subprocess.popen on the 'rename' function in linux. When I run the command from the shell, like so: rename -vn 's/\.htm$/\.html/' *.htm it works fine... however when I...
4
by: geoffbache | last post by:
Hi all, I've always wondered why os.kill isn't supported on Windows. I found a discussion somewhere from 2006 about this so it seems others have wanted it, but still nothing. So I have a...
0
by: Gary Josack | last post by:
Cameron Simpson wrote: Use of the popen functions is generally discouraged since being deprecated for the subprocess module. Look at the subprocess module which will allow you to run processes...
1
by: Mswed | last post by:
Hi all! 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...
1
by: Gabriel Genellina | last post by:
En Tue, 29 Jul 2008 10:04:46 -0300, Gordon Maria <Maria.Gordon@afconsult.comescribi�: You should call os.waitpid() after killing the child process, to let the OS free the resources allocated...
6
by: Tim Arnold | last post by:
I have a bunch of processes to run and each one needs its own working directory. I'd also like to know when all of the processes are finished. (1) First thought was threads, until I saw that...
1
by: Mark Shewfelt | last post by:
Hello, I am attempting to use Popen() in a Windows service. I have a small Win32 .exe that I normally run through the os.popen2() function. I've written a class to work with the input and output...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.