()
Turn the process into daemon.

    Goes background and disables all i/o.
Turn the process into daemon.
Turn the process into daemon .
def daemonize():
    """Turn the process into daemon.

    Goes background and disables all i/o.
    """

    # launch new process, kill parent
    pid = os.fork()
    if pid != 0:
        os._exit(0)

    # start new session
    os.setsid()

    # stop i/o
    fd = os.open("/dev/null", os.O_RDWR)
    os.dup2(fd, 0)
    os.dup2(fd, 1)
    os.dup2(fd, 2)
    if fd > 2:
        os.close(fd)
def daemonize ( ) : # launch new process, kill parent pid = os . fork ( ) if pid != 0 : os . _exit ( 0 ) # start new session os . setsid ( ) # stop i/o fd = os . open ( "/dev/null" , os . O_RDWR ) os . dup2 ( fd , 0 ) os . dup2 ( fd , 1 ) os . dup2 ( fd , 2 ) if fd > 2 : os . close ( fd )