[Python]一个简单的守护进程
时间:2007-09-21 来源:mystérieux
import os
import sys
def create_daemon():
pid = os.fork()
if pid == 0:
os.setsid()
if pid == 0:
os.chdir('/usr/python/daemon')
os.umask(0)
else:
os._exit(0)
else:
os._exit(0)
if __name__ == "__main__"
create_daemon()
...
import sys
def create_daemon():
pid = os.fork()
if pid == 0:
os.setsid()
if pid == 0:
os.chdir('/usr/python/daemon')
os.umask(0)
else:
os._exit(0)
else:
os._exit(0)
if __name__ == "__main__"
create_daemon()
...
相关阅读 更多 +