[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Do any one know how to make a daemon in python



> In Python, you can use os.fork() and os.setsid() which are the substitutes
> of C's fork() and setsid() (of course, you need to import os library).
>
>
I tried that
it did not work,
I write a small script that do
from os import *
from time import * # or something like that
def loop():
  for i in xrange(65000): print i; sleep(i)
#main
p=fork()
if p==0: loop()
else: print "this is the parent, child pid=%d\ndone\n" % p

and when I run it then close the terminal then open another one and type
ps ax | grep python
it did not appear

while the same code in C works

> http://homepage.hispeed.ch/py430/python/daemon.py
>
please send it to my email as an attachement, I don't have internet
please,