Python and Daemons
ruud de rooij
* at spam.ruud.org
Wed Feb 27 12:04:16 EST 2002
> > def daemonize():
> > "cause this process to becaome a daemon"
> > if os.fork() != 0:
> > os._exit(0)
> > os.setsid()
> > if os.fork() != 0: # 2nd fork is widely recommended
> > os._exit(0) # though not always needed
> > debugmsg("daemonized")
> Can someone say why the 2nd fork is widely recommneded?
http://www.erlenstar.demon.co.uk/unix/faq_2.html#SEC16
3. fork() again so the parent, (the session group leader), can
exit. This means that we, as a non-session group leader, can never
regain a controlling terminal.
- ruud
--
ruud de rooij | *@spam.ruud.org | http://ruud.org
More information about the Python-list
mailing list