Daemonizing python

2006-09-24 Thread NinjaZombie
Hi!

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.
Thanks.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Daemonizing python

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

> Paul Rubin wrote:
>> NinjaZombie <[EMAIL PROTECTED]> 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.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Daemonizing python

2006-09-24 Thread NinjaZombie
Na dan Sun, 24 Sep 2006 14:35:31 -0700, Paul Rubin je napisao:
> Try it this way:
> 
>  import os, sys
>  print "Entering program"
> 
>  if os.fork():
> sys.exit()  # parent process exits so shell returns
> 
>  while (1): # child process continues
> pass# some other work

This works! Thanks a bunch, Paul.
-- 
http://mail.python.org/mailman/listinfo/python-list