473,544 Members | 1,957 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

subprocess.Pope n generates defunct

2 New Member
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 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?

My code snippets:
#Launching a separate process (no communication in between the process needed)
# When closing the GUI, the launched program should not be killed.

command = ['test.py',' -c ',config]
process = subprocess.Pope n(command, preexec_fn = os.setsid)

On request from GUI I do the following:
os.kill(process .pid,9)

It is all running on Linux.

Anyone knows why I'm getting the defunc problem?

-Maria
Jul 29 '08 #1
1 9787
Mswed
2 New Member
Ok, found what was missing.

Tips for anyone encountering similar problems, after the kill add a line with
os.wait()

Have a great day everybody!
Jul 29 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
10021
by: John Abel | last post by:
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, executable=cmdLine, close_fds=True ).pid
12
10966
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 the old module and cmd is the command I wish to try) all the output seems to be returned as one line (at least when I run the program in spe). ...
9
6466
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 hangs at this point. How should I handle these kind of commands (ping 127.0.0.1) with
12
4514
by: bhunter | last post by:
Hi, I've used subprocess with 2.4 several times to execute a process, wait for it to finish, and then look at its output. Now I want to spawn the process separately, later check to see if it's finished, and if it is look at its output. I may want to send a signal at some point to kill the process. This seems straightforward, but it...
7
4901
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 try to do it in python like so: p = subprocess.Popen(,stdout=subprocess.PIPE,stderr=subprocess.PIPE) print p.communicate()
1
2679
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 to it. -- Gabriel Genellina
25
2749
by: Jeremy Banks | last post by:
Hi. I wondered if anyone knew the rationale behind the naming of the Popen class in the subprocess module. Popen sounds like the a suitable name for a function that created a subprocess, but the object itself is a subprocess, not a "popen". It seems that it would be more accurate to just name the class Subprocess, can anyone explain why this...
1
8567
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 parameters that are passed and captured from this exe. When I use the class outside of a service using either subprocess.Popen or os.popen2 work...
5
4117
by: thedsadude | last post by:
Hello, I'm launching a script as follows: <code> p = subprocess.Popen() p.wait() </code> If p.py writes to sys.stdout, then it is shown on the console.
0
7431
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7617
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7779
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7387
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7714
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5305
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4924
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3415
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1848
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.