I'm using the Python processing module. I've just run into a problem
though. Actually, it's a more general problem that isn't specific to
this module, but to the handling of Unix (Linux processes) in general.
Suppose for instance that for some reason or another, after forking
several child processes, the main process terminates or gets killed
(or segfaults or whatever) and the child processes are orphaned. Is
there any way to automatically arrange things so that they auto-
terminate or, in other words, is there a way to make the child
processes terminate when the parent terminates?
Thank you. 2 2078 ro*********@gma il.com wrote:
I'm using the Python processing module. I've just run into a problem
though. Actually, it's a more general problem that isn't specific to
this module, but to the handling of Unix (Linux processes) in general.
Suppose for instance that for some reason or another, after forking
several child processes, the main process terminates or gets killed
(or segfaults or whatever) and the child processes are orphaned. Is
there any way to automatically arrange things so that they auto-
terminate or, in other words, is there a way to make the child
processes terminate when the parent terminates?
Thank you.
Put a thread in the child which reads stdin, and make stdin
connect to a pipe from the parent. When the parent terminates,
the child will get a SIGPIPE error and raise an exception.
John Nagle
In article <47************ ***********@new s.sonic.net>,
John Nagle <na***@animats. comwrote: ro*********@gma il.com wrote:
I'm using the Python processing module. I've just run into a problem
though. Actually, it's a more general problem that isn't specific to
this module, but to the handling of Unix (Linux processes) in general.
Suppose for instance that for some reason or another, after forking
several child processes, the main process terminates or gets killed
(or segfaults or whatever) and the child processes are orphaned. Is
there any way to automatically arrange things so that they auto-
terminate or, in other words, is there a way to make the child
processes terminate when the parent terminates?
Thank you.
Put a thread in the child which reads stdin, and make stdin
connect to a pipe from the parent. When the parent terminates,
the child will get a SIGPIPE error and raise an exception.
John Nagle
That could work, but not precisely in that manner. You get
SIGPIPE when you write to a closed pipe. When you read from one,
you get end of file, i.e., a normal return with 0 bytes.
When you test it, make sure to try a configuration with more
than one child process. Since the parent holds the write end
of the pipe, subsequently forked child processes could easily
inherit it, and they'll hold it open and spoil the effect.
Donn Cave, do**@u.washingt on.edu This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Markus Franz |
last post by:
Hi.
I created a little script:
for currenturl in sys.argv:
pid = os.fork()
if pid == 0:
signal.alarm(10)
do_something() # placeholder for the download and print
routine
|
by: Bob Swerdlow |
last post by:
My application starts up a number of processes for various purposes using:
self.popen = popen2.Popen3("/usr/local/bin/python -O "myscript.py")
and then shuts them down when appropriate with
os.kill(self.popen.pid, signal.SIGTERM)
Everything works fine on MacOSX. However, I'm doing a port to Solaris (so I
can run it on my web site) and find that the child processes are not
stopping! Solaris is creating TWO new processes: one for the SHELL...
|
by: Rech |
last post by:
Hi,
I need a little help here managing child processes in Python. I'm not so
skilled in system programming so I hope you can give me some good
suggestions.
I have a very CPU and memory intensive task that has to be repeated many
times (with different input parameters). So I've thought to write a
Python script that create a child process, wait for it to finish and
then starts again another child with different parameters.
|
by: Jason Godden |
last post by:
Hi All,
I've written a few C functions in the version 1 format as well as some SPI
based backend bits and I'm curious as to how PG treats these items when used
within plpgsql.
The set of functions control external processes. One function is called with
various items governed by the db, does a fork and then execl to from the
child to start a new process. Whilst it's not posix i ignore the SIGCHLD
signal and let the parent process...
|
by: tiger |
last post by:
Hi
I was working on a project for school, that deals with processes and
windows.....here is a sample of the instruction:
You are to implement a game of Nim. Your implementation should consist of
three processes. Each process must have a visible window as it runs. The
main process is the manager. It should start the other two (player)
processes and manage the game. It is responsible for evaluating the game and
declaring a winner or a...
| |
by: tiger |
last post by:
Hi
I was working on a project for school, that deals with processes and
windows.....here is a sample of the instruction:
You are to implement a game of Nim. Your implementation should consist of
three processes. Each process must have a visible window as it runs. The
main process is the manager. It should start the other two (player)
processes and manage the game. It is responsible for evaluating the game and
declaring a winner or a...
|
by: Wizou |
last post by:
1. Create a TcpListener
2. Start a child Process
3. Kill the parent process
=> You can't bind to the port until you close the child process
Variant :
3. Terminate normally the parent process
=> The parent process stays as "Running" until the child process is
closed
|
by: Fred Heida |
last post by:
Hi,
Question on Vista Run As Administrator. If i have exe which creates a child
process, using the Process class, and
this exe is Run As Asministror, is there a way to have the child process
also Run As Asministror with out confirmation for this (as this is already
doen my the main process) ?
Cheers,
|
by: Jason Zheng |
last post by:
This may be a silly question but is possible for os.wait() to lose track
of child processes? I'm running Python 2.4.4 on Linux kernel 2.6.20
(i686), gcc4.1.1, and glibc-2.5.
Here's what happened in my situation. I first created a few child
processes with Popen, then in a while(True) loop wait on any of the
child process to exit, then restart a child process:
import os
from subprocess import Popen
|
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 usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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 captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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 into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |