Python daemon process

  • Thread starter Thomas Dybdahl Ahle
  • Start date
T

Thomas Dybdahl Ahle

Hi, I'm writing a program, using popen4(gnuchess),
The problem is, that gnuchess keeps running after program exit.

I know about the atexit module, but in java, you could make a process a
daemon process, and it would only run as long as the real processes ran. I
think this is a better way to stop gnuchess, as you are 100% sure, that
it'll stop.

Can you do this with popen?
 
P

Paolo Pantaleo

2006/8/26 said:
Hi, I'm writing a program, using popen4(gnuchess),
The problem is, that gnuchess keeps running after program exit.

I know about the atexit module, but in java, you could make a process a
daemon process, and it would only run as long as the real processes ran. I
think this is a better way to stop gnuchess, as you are 100% sure, that
it'll stop.

Can you do this with popen?
You could send the quit (or close or wahtever) command to gnuchess
when you want it to terminate. Supposing that gnuchess needs to do
some stuff on exit, this is a better solution.

PAolo
 
T

Thomas Dybdahl Ahle

I might not have made myself very clear, since you both got me wrong.
What I need, is not a method to terminate a process, but a way to
terminate a process when the main process dies.

From the atexit module info:
Note: the functions registered via this module are not called when the
program is killed by a signal, when a Python fatal internal error is
detected, or when os._exit() is called.

I belive that there is noway you can be sure to get a piece of code run,
if the program crashes or something like that,
therefor I ask for a way to run gnuchess as a kind of subprocess, that can
only run when the parrentprocess is still running.

I know this is called a daemon thread in java.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top