code: func monitorResizeEvents(fd uintptr, resizeEvents chan<- remotecommand.TerminalSize, stop chan struct{}) {
  	go func() {
  		defer runtime.HandleCrash()
  
  		size := GetSize(fd)
  		if size == nil {
  			return
  		}
  		lastSize := *size
  
  		for {
  			// see if we need to stop running
  			select {
  			case <-stop:
  				return
  			default:
  			}
  
  			size := GetSize(fd)
  			if size == nil {
  				return
  			}
  
  			if size.Height != lastSize.Height || size.Width != lastSize.Width {
  				lastSize.Height = size.Height
  				lastSize.Width = size.Width
  				resizeEvents <- *size
  			}
  
  			// sleep to avoid hot looping
  			time.Sleep(250 * time.Millisecond)
  		}
  	}()
  }
docs: // monitorResizeEvents spawns a goroutine that periodically gets the terminal size and tries to send
  // it to the resizeEvents channel if the size has changed. The goroutine stops when the stop channel
  // is closed.