code: def Detach(self):
      
      # We have to work around the python APIs weirdness :\
      if not self.IsAttached():
        return None
      # Gdb doesn't drain any pending SIGINTs it may have sent to the inferior
      # when it simply detaches. We can do this by letting the inferior continue,
      # and gdb will intercept any SIGINT that's still to-be-delivered; as soon as
      # we do so however, we may lose control of gdb (if we're running in
      # synchronous mode). So we queue an interruption and continue gdb right
      # afterwards, it will waitpid() for its inferior and collect all signals
      # that may have been queued.
      pid = gdb.selected_inferior().pid
      self.Interrupt([pid, None, None])
      self.Continue([pid, None, None])
      result = gdb.execute('detach', to_string=True)
      if not result:
        return None
      return result
docs: Detaches from the inferior. If not attached, this is a no-op.