code: def input_thread(log, stdin, is_alive, quit, close_before_term):
      
  
      done = False
      closed = False
      alive = True
      poller = Poller()
      poller.register_write(stdin)
  
      while poller and alive:
          changed = poller.poll(1)
          for fd, events in changed:
              if events & (POLLER_EVENT_WRITE | POLLER_EVENT_HUP):
                  log.debug("%r ready for more input", stdin)
                  done = stdin.write()
  
                  if done:
                      poller.unregister(stdin)
                      if close_before_term:
                          stdin.close()
                          closed = True
  
          alive, _ = is_alive()
  
      while alive:
          quit.wait(1)
          alive, _ = is_alive()
  
      if not closed:
          stdin.close()
docs: this is run in a separate thread.  it writes into our process's
      stdin (a streamwriter) and waits the process to end AND everything that
      can be written to be written