Class AbstractPty

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable, Pty
    Direct Known Subclasses:
    ExecPty, JansiNativePty, JnaNativePty, JniNativePty

    public abstract class AbstractPty
    extends java.lang.Object
    implements Pty
    Base implementation of the Pty interface.

    The AbstractPty class provides a common foundation for pseudoterminal (PTY) implementations. It handles common functionality such as system stream management and provider access, while leaving platform-specific PTY operations to be implemented by concrete subclasses.

    This class serves as the base for various PTY implementations, including:

    • Native PTY implementations (JNI, JNA, FFM) for direct access to system PTYs
    • Exec PTY implementation that uses external commands

    The AbstractPty maintains information about the associated system stream and terminal provider, which are common to all PTY implementations regardless of the underlying mechanism used to interact with the terminal.

    See Also:
    Pty
    • Method Detail

      • setAttr

        public void setAttr​(Attributes attr)
                     throws java.io.IOException
        Description copied from interface: Pty
        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.

        Specified by:
        setAttr in interface Pty
        Parameters:
        attr - the terminal attributes to set
        Throws:
        java.io.IOException - if an I/O error occurs
        See Also:
        Attributes
      • getSlaveInput

        public java.io.InputStream getSlaveInput()
                                          throws java.io.IOException
        Description copied from interface: Pty
        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.

        Specified by:
        getSlaveInput in interface Pty
        Returns:
        the slave's input stream
        Throws:
        java.io.IOException - if an I/O error occurs
      • doSetAttr

        protected abstract void doSetAttr​(Attributes attr)
                                   throws java.io.IOException
        Throws:
        java.io.IOException
      • doGetSlaveInput

        protected abstract java.io.InputStream doGetSlaveInput()
                                                        throws java.io.IOException
        Throws:
        java.io.IOException
      • checkInterrupted

        protected void checkInterrupted()
                                 throws java.io.InterruptedIOException
        Throws:
        java.io.InterruptedIOException
      • getProvider

        public TerminalProvider getProvider()
        Description copied from interface: Pty
        Returns the terminal provider that created this PTY.

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

        Specified by:
        getProvider in interface Pty
        Returns:
        the terminal provider that created this PTY
        See Also:
        TerminalProvider
      • getSystemStream

        public SystemStream getSystemStream()
        Description copied from interface: Pty
        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.

        Specified by:
        getSystemStream in interface Pty
        Returns:
        the associated system stream, or null if this PTY is not associated with a system stream
        See Also:
        SystemStream
      • newDescriptor

        protected static java.io.FileDescriptor newDescriptor​(int fd)