473,499 Members | 1,948 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Python daemon process

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
Aug 26 '06 #1
3 5185
process = subprocess.Popen(gnuchess)
....
os.kill(process.pid, signal.SIGKILL)

Thomas Dybdahl Ahle wrote:
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
Aug 26 '06 #2
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

--
if you have a minute to spend please visit my photogrphy site:
http://mypic.co.nr
Aug 27 '06 #3
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.

Aug 29 '06 #4

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

Similar topics

2
1451
by: Aienthiwan | last post by:
Ok - this one's a baffling one. I have a Python script run in cgi, it accesses a directory... /var/foo. The permissions on /var/foo are 770 with an ownership of mark:dbtest. The permissions...
1
2129
by: Bob Swerdlow | last post by:
I've created a Python daemon that starts a bunch of BitTorrent downloader process. Everything is working fine when I start the daemon by hand (logged on as root). I can quit the session and see...
1
3541
by: David Pratt | last post by:
Hi. I am running a zope server. Zope runs 4 threads and I have a document processing method that can require minutes to run so I do not want to run out of threads. A solution to this is to run...
3
2596
by: zxo102 | last post by:
Hi there, I have a python application (many python scripts) and I start the application like this python myServer.py start in window. It is running in dos window. Now I would like to put it...
5
2170
by: Melissa Evans | last post by:
Hi. I'm new to Python. :) I've modified grappy.py, http://www.stacken.kth.se/~mattiasa/projects/grappy/, a postfix policy daemon for greylisting. to use LDAP as a backend instead of SQL (with...
852
27935
by: Mark Tarver | last post by:
How do you compare Python to Lisp? What specific advantages do you think that one has over the other? Note I'm not a Python person and I have no axes to grind here. This is just a question for...
9
9116
by: Sakagami Hiroki | last post by:
Hi, What is the easiest way to create a daemon process in Python? Google says I should call fork() and other system calls manually, but is there no os.daemon() and the like? Regards, --...
2
1123
by: Michael Palmer | last post by:
On Sep 5, 9:56 pm, Sean Davis <seand...@gmail.comwrote: xmlrpc is the right idea, as it interfaces easily across languages.
0
7012
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7180
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,...
0
7225
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...
0
7392
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...
1
4920
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
4605
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
3101
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
667
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
307
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.