github.com/dolfly/pty@v1.2.1/doc.go (about)

     1  // Package pty provides functions for working with Unix terminals.
     2  package pty
     3  
     4  import (
     5  	"errors"
     6  	"io"
     7  )
     8  
     9  // ErrUnsupported is returned if a function is not
    10  // available on the current platform.
    11  var ErrUnsupported = errors.New("unsupported")
    12  
    13  // Open a pty and its corresponding tty.
    14  func Open() (Pty, Tty, error) {
    15  	return open()
    16  }
    17  
    18  type (
    19  	FdHolder interface {
    20  		Fd() uintptr
    21  	}
    22  
    23  	// Pty for terminal control in current process
    24  	// for unix systems, the real type is *os.File
    25  	// for windows, the real type is a *WindowsPty for ConPTY handle
    26  	Pty interface {
    27  		// Fd intended to resize Tty of child process in current process
    28  		FdHolder
    29  
    30  		// WriteString is only used to identify Pty and Tty
    31  		WriteString(s string) (n int, err error)
    32  		io.ReadWriteCloser
    33  	}
    34  
    35  	// Tty for data i/o in child process
    36  	// for unix systems, the real type is *os.File
    37  	// for windows, the real type is a *WindowsTty, which is a combination of two pipe file
    38  	Tty interface {
    39  		// Fd only intended for manual InheritSize from Pty
    40  		FdHolder
    41  
    42  		io.ReadWriteCloser
    43  	}
    44  )