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.
2006/8/26, Thomas Dybdahl Ahle <th****@localhost.localdomain>:
>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?
--
Thomas
--
http://mail.python.org/mailman/listinfo/python-list
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
--
Programmers should realize their critical importance and responsibility in a
world gone digital. They are in many ways similar to the priests and monks of
Europe's Dark Ages; they are the only ones with the training and insight
to read and interpret the "scripture" of this age.