##// END OF EJS Templates
Merge pull request #964 from takluyver/default-profile...
Merge pull request #964 from takluyver/default-profile Python 3 being fully supported, it is no longer relegated to a special profile. Users of both Python 3 and Python 2 will now get the same default profile (history, config, etc.) in each. Closes gh-939, fixing the profile directory and magic in the IPython kernel.

File last commit:

r4019:3c996c36
r5265:c3d885fa merge
Show More
daemonize.py
26 lines | 831 B | text/x-python | PythonLexer
"""daemonize function from twisted.scripts._twistd_unix."""
#-----------------------------------------------------------------------------
# Copyright (c) Twisted Matrix Laboratories.
# See Twisted's LICENSE for details.
# http://twistedmatrix.com/
#-----------------------------------------------------------------------------
import os, errno
def daemonize():
# See http://www.erlenstar.demon.co.uk/unix/faq_toc.html#TOC16
if os.fork(): # launch child and...
os._exit(0) # kill off parent
os.setsid()
if os.fork(): # launch child and...
os._exit(0) # kill off parent again.
null = os.open('/dev/null', os.O_RDWR)
for i in range(3):
try:
os.dup2(null, i)
except OSError, e:
if e.errno != errno.EBADF:
raise
os.close(null)