docs: def dup2(a, b, timeout=3):
      """Like os.dup2, but retry on EBUSY"""
      dup_err = None
      # give FDs 3 seconds to not be busy anymore
      for i in range(int(10 * timeout)):
          try:
              return os.dup2(a, b)
          except OSError as e:
              dup_err = e
              if e.errno == errno.EBUSY:
                  time.sleep(0.1)
              else:
                  raise
      if dup_err:
          raise dup_err