code: func (ec *EpollConsole) Write(p []byte) (n int, err error) {
  	var written int
  	ec.writec.L.Lock()
  	defer ec.writec.L.Unlock()
  	for {
  		written, err = ec.Console.Write(p[n:])
  		n += written
  		if err != nil {
  			var hangup bool
  			if perr, ok := err.(*os.PathError); ok {
  				hangup = (perr.Err == unix.EAGAIN || perr.Err == unix.EIO)
  			} else {
  				hangup = (err == unix.EAGAIN || err == unix.EIO)
  			}
  			// if the other end disappears, assume this is temporary and wait for the
  			// signal to continue again.
  			if hangup {
  				ec.writec.Wait()
  				continue
  			}
  		}
  		// unrecoverable error, break the loop and return the error
  		break
  	}
  	if n < len(p) && err == nil {
  		err = io.ErrShortWrite
  	}
  	// signal for others that we finished the write
  	ec.writec.Signal()
  	return n, err
  }
docs: // Writes len(p) bytes from p to the console. It returns the number of bytes
  // written from p (0 <= n <= len(p)) and any error encountered that caused
  // the write to stop early.
  //
  // If writes to the console returns EAGAIN or EIO, we assume that it's a
  // temporary error because the other side went away and wait for the signal
  // generated by epoll event to continue.