def detach_process():
    """
    Detach the current process from the controlling terminal by using a
    double fork. Can be used only on platforms with fork (no Windows).
    """
    # see https://pagure.io/python-daemon/blob/master/f/daemon/daemon.py and
    # https://stackoverflow.com/questions/45911705/why-use-os-setsid-in-python
    def fork_then_exit_parent():
        pid = os.fork()
        if pid:  # in parent
            os._exit(0)
    fork_then_exit_parent()
    os.setsid()
    fork_then_exit_parent()
def detach_process ( ) : def fork_then_exit_parent ( ) : pid = os . fork ( ) if pid : os . _exit ( 0 ) fork_then_exit_parent ( ) os . setsid ( ) fork_then_exit_parent ( )
Detach the current process from the controlling terminal by using a
    double fork. Can be used only on platforms with fork (no Windows).