def daemonize():
    """
    Forks and daemonizes the current process. Does not automatically track
    the process id; to do this, use :class:`Exscript.util.pidutil`.
    """
    sys.stdout.flush()
    sys.stderr.flush()

    # UNIX double-fork magic. We need to fork before any threads are
    # created.
    pid = os.fork()
    if pid > 0:
        # Exit first parent.
        sys.exit(0)

    # Decouple from parent environment.
    os.chdir('/')
    os.setsid()
    os.umask(0)

    # Now fork again.
    pid = os.fork()
    if pid > 0:
        # Exit second parent.
        sys.exit(0)

    _redirect_output(os.devnull)
Forks and daemonizes the current process. Does not automatically track
    the process id; to do this, use :class:`Exscript.util.pidutil`.