Interface Pty

All Superinterfaces:
AutoCloseable, Closeable
All Known Implementing Classes:
AbstractExecPty, CygwinPty, ExecPty

public interface Pty extends Closeable
Represents a pseudo-terminal (PTY) providing master/slave input and output streams. A PTY allows a program to interact with a terminal device, providing both the master side (for the controlling process) and the slave side (for the terminal).
  • Method Summary

    Modifier and Type
    Method
    Description
    org.aesh.terminal.Attributes
    Returns the current terminal attributes.
    Returns the master side input stream.
    Returns the master side output stream.
    org.aesh.terminal.tty.Size
    Returns the current terminal size.
    Returns the slave side input stream.
    Returns the slave side output stream.
    default int
    peek(long timeoutMs)
    Peeks at the next byte without consuming it, with a timeout.
    default int
    read(byte[] b, int off, int len, long timeoutMs)
    Reads multiple bytes with a timeout for the first byte.
    default int
    read(long timeoutMs)
    Reads a single byte with a timeout.
    void
    setAttr(org.aesh.terminal.Attributes attr)
    Sets the terminal attributes.
    default boolean
    Whether this PTY supports non-blocking read operations with timeouts.

    Methods inherited from interface Closeable

    close
  • Method Details

    • getMasterInput

      InputStream getMasterInput()
      Returns the master side input stream.
      Returns:
      the master input stream
    • getMasterOutput

      OutputStream getMasterOutput()
      Returns the master side output stream.
      Returns:
      the master output stream
    • getSlaveInput

      InputStream getSlaveInput()
      Returns the slave side input stream.
      Returns:
      the slave input stream
    • getSlaveOutput

      OutputStream getSlaveOutput()
      Returns the slave side output stream.
      Returns:
      the slave output stream
    • getAttr

      org.aesh.terminal.Attributes getAttr() throws IOException
      Returns the current terminal attributes.
      Returns:
      the terminal attributes
      Throws:
      IOException - if an I/O error occurs
    • setAttr

      void setAttr(org.aesh.terminal.Attributes attr) throws IOException
      Sets the terminal attributes.
      Parameters:
      attr - the attributes to set
      Throws:
      IOException - if an I/O error occurs
    • getSize

      org.aesh.terminal.tty.Size getSize() throws IOException
      Returns the current terminal size.
      Returns:
      the terminal size
      Throws:
      IOException - if an I/O error occurs
    • supportsNonBlockingRead

      default boolean supportsNonBlockingRead()
      Whether this PTY supports non-blocking read operations with timeouts.
      Returns:
      true if non-blocking reads are supported
    • read

      default int read(long timeoutMs) throws IOException
      Reads a single byte with a timeout.

      Default implementation delegates to getSlaveInput().read(), ignoring the timeout (blocking).

      Parameters:
      timeoutMs - timeout in milliseconds; 0 for non-blocking, negative for infinite
      Returns:
      the byte read (0-255), -1 for EOF, or Terminal.READ_EXPIRED for timeout
      Throws:
      IOException - if an I/O error occurs
    • peek

      default int peek(long timeoutMs) throws IOException
      Peeks at the next byte without consuming it, with a timeout.

      Default implementation returns Terminal.READ_EXPIRED (no peek support).

      Parameters:
      timeoutMs - timeout in milliseconds; 0 for non-blocking
      Returns:
      the byte peeked (0-255), -1 for EOF, or Terminal.READ_EXPIRED for timeout
      Throws:
      IOException - if an I/O error occurs
    • read

      default int read(byte[] b, int off, int len, long timeoutMs) throws IOException
      Reads multiple bytes with a timeout for the first byte.

      After the first byte arrives (or timeout), reads additional bytes that are immediately available without blocking.

      Default implementation delegates to getSlaveInput().read(b, off, len), ignoring the timeout (blocking).

      Parameters:
      b - the buffer to read into
      off - the offset in the buffer
      len - the maximum number of bytes to read
      timeoutMs - timeout in milliseconds for the first byte
      Returns:
      the number of bytes read, -1 for EOF, or Terminal.READ_EXPIRED for timeout
      Throws:
      IOException - if an I/O error occurs