code: def detach_process():
      
      # 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()
docs: Detach the current process from the controlling terminal by using a
      double fork. Can be used only on platforms with fork (no Windows).