Interface Pty

All Superinterfaces:
AutoCloseable, Closeable
All Known Implementing Classes:
AbstractPty, ExecPty, FreeBsdNativePty, FreeBsdNativePty, FreeBsdNativePty, JansiNativePty, JnaNativePty, JniNativePty, LinuxNativePty, LinuxNativePty, LinuxNativePty, OsXNativePty, OsXNativePty, OsXNativePty, SolarisNativePty, SolarisNativePty, SolarisNativePty

public interface Pty extends Closeable
Represents a pseudoterminal (PTY) that provides terminal emulation.

A pseudoterminal (PTY) is a pair of virtual character devices that provide a bidirectional communication channel. The PTY consists of a master side and a slave side. The slave side appears as a terminal device to processes, while the master side is used by terminal emulators to control the slave side.

This interface provides methods to access the input and output streams for both the master and slave sides of the PTY, as well as methods to get and set terminal attributes and size.

PTY implementations are typically platform-specific and may use different underlying mechanisms depending on the operating system (e.g., /dev/pts on Unix-like systems).

See Also:
  • Method Details

    • getMasterInput

      InputStream getMasterInput() throws IOException
      Returns the input stream for the master side of the PTY.

      This stream receives data that has been written to the slave's output stream. Terminal emulators typically read from this stream to get the output from processes running in the terminal.

      Returns:
      the master's input stream
      Throws:
      IOException - if an I/O error occurs
    • getMasterOutput

      OutputStream getMasterOutput() throws IOException
      Returns the output stream for the master side of the PTY.

      Data written to this stream will be available for reading from the slave's input stream. Terminal emulators typically write to this stream to send input to processes running in the terminal.

      Returns:
      the master's output stream
      Throws:
      IOException - if an I/O error occurs
    • getSlaveInput

      InputStream getSlaveInput() throws IOException
      Returns the input stream for the slave side of the PTY.

      This stream receives data that has been written to the master's output stream. Processes running in the terminal read from this stream to get their input.

      Returns:
      the slave's input stream
      Throws:
      IOException - if an I/O error occurs
    • getSlaveOutput

      OutputStream getSlaveOutput() throws IOException
      Returns the output stream for the slave side of the PTY.

      Data written to this stream will be available for reading from the master's input stream. Processes running in the terminal write to this stream to produce their output.

      Returns:
      the slave's output stream
      Throws:
      IOException - if an I/O error occurs
    • getAttr

      Attributes getAttr() throws IOException
      Returns the current terminal attributes for this PTY.

      Terminal attributes control various aspects of terminal behavior, such as echo settings, line discipline, and control characters.

      Returns:
      the current terminal attributes
      Throws:
      IOException - if an I/O error occurs
      See Also:
    • setAttr

      void setAttr(Attributes attr) throws IOException
      Sets the terminal attributes for this PTY.

      This method allows changing various aspects of terminal behavior, such as echo settings, line discipline, and control characters.

      Parameters:
      attr - the terminal attributes to set
      Throws:
      IOException - if an I/O error occurs
      See Also:
    • getSize

      Size getSize() throws IOException
      Returns the current size (dimensions) of this PTY.

      The size includes the number of rows and columns in the terminal window.

      Returns:
      the current terminal size
      Throws:
      IOException - if an I/O error occurs
      See Also:
    • setSize

      void setSize(Size size) throws IOException
      Sets the size (dimensions) of this PTY.

      This method changes the number of rows and columns in the terminal window. When the size changes, a SIGWINCH signal is typically sent to processes running in the terminal.

      Parameters:
      size - the new terminal size to set
      Throws:
      IOException - if an I/O error occurs
      See Also:
    • getSystemStream

      SystemStream getSystemStream()
      Returns the system stream associated with this PTY, if any.

      The system stream indicates whether this PTY is connected to standard input, standard output, or standard error.

      Returns:
      the associated system stream, or null if this PTY is not associated with a system stream
      See Also:
    • getProvider

      TerminalProvider getProvider()
      Returns the terminal provider that created this PTY.

      The terminal provider is responsible for creating and managing terminal instances on a specific platform.

      Returns:
      the terminal provider that created this PTY
      See Also: