Interface Pty
- All Superinterfaces:
AutoCloseable
,Closeable
- All Known Implementing Classes:
AbstractPty
,ExecPty
,FreeBsdNativePty
,JniNativePty
,LinuxNativePty
,OsXNativePty
,SolarisNativePty
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 Summary
Modifier and TypeMethodDescriptiongetAttr()
Returns the current terminal attributes for this PTY.Returns the input stream for the master side of the PTY.Returns the output stream for the master side of the PTY.Returns the terminal provider that created this PTY.getSize()
Returns the current size (dimensions) of this PTY.Returns the input stream for the slave side of the PTY.Returns the output stream for the slave side of the PTY.Returns the system stream associated with this PTY, if any.void
setAttr
(Attributes attr) Sets the terminal attributes for this PTY.void
Sets the size (dimensions) of this PTY.
-
Method Details
-
getMasterInput
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
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
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
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
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
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
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
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:
-