Daemonizing python

NinjaZombie ninjazombie at net.hr
Sun Sep 24 17:25:30 EDT 2006


Na dan Sun, 24 Sep 2006 23:19:12 +0200, Bjoern Schliessmann je napisao:

> Paul Rubin wrote:
>> NinjaZombie <ninjazombie at net.hr> writes:
> 
>>> I was wondering if it is possible to turn the current python
>>> proccess into a unix daemon, but not doing it like this:
>>> python myscript.py &
>>> but from code programaticaly.
>  
>> Yeah, os.fork and the parent process exits.
> 
> Or little helpers like twistd -- only feasible if you use Twisted
> though.

Thanks guys, but I'm a little new to this. Take a look at this very simple
code:

import os
print "Entering program"
os.fork()
while (1):
	pass    # some other work


I was expexting that after 'os.fork()', the rest of the program would run
in the background, which it isn't.



More information about the Python-list mailing list