Interface Pty

  • All Superinterfaces:
    java.lang.AutoCloseable, java.io.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 java.io.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:
    Closeable
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      Attributes getAttr()
      Returns the current terminal attributes for this PTY.
      java.io.InputStream getMasterInput()
      Returns the input stream for the master side of the PTY.
      java.io.OutputStream getMasterOutput()
      Returns the output stream for the master side of the PTY.
      TerminalProvider getProvider()
      Returns the terminal provider that created this PTY.
      Size getSize()
      Returns the current size (dimensions) of this PTY.
      java.io.InputStream getSlaveInput()
      Returns the input stream for the slave side of the PTY.
      java.io.OutputStream getSlaveOutput()
      Returns the output stream for the slave side of the PTY.
      SystemStream getSystemStream()
      Returns the system stream associated with this PTY, if any.
      void setAttr​(Attributes attr)
      Sets the terminal attributes for this PTY.
      void setSize​(Size size)
      Sets the size (dimensions) of this PTY.
      • Methods inherited from interface java.io.Closeable

        close
    • Method Detail

      • getMasterInput

        java.io.InputStream getMasterInput()
                                    throws java.io.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:
        java.io.IOException - if an I/O error occurs
      • getMasterOutput

        java.io.OutputStream getMasterOutput()
                                      throws java.io.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:
        java.io.IOException - if an I/O error occurs
      • getSlaveInput

        java.io.InputStream getSlaveInput()
                                   throws java.io.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:
        java.io.IOException - if an I/O error occurs
      • getSlaveOutput

        java.io.OutputStream getSlaveOutput()
                                     throws java.io.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:
        java.io.IOException - if an I/O error occurs
      • getAttr

        Attributes getAttr()
                    throws java.io.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:
        java.io.IOException - if an I/O error occurs
        See Also:
        Attributes
      • setAttr

        void setAttr​(Attributes attr)
              throws java.io.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:
        java.io.IOException - if an I/O error occurs
        See Also:
        Attributes
      • getSize

        Size getSize()
              throws java.io.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:
        java.io.IOException - if an I/O error occurs
        See Also:
        Size
      • setSize

        void setSize​(Size size)
              throws java.io.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:
        java.io.IOException - if an I/O error occurs
        See Also:
        Size
      • 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:
        SystemStream
      • 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:
        TerminalProvider