KetraTerm
API · DevelopmentAll versions

PtyConnector

TerminalConnector backed by a local PTY process.

This connector owns PTY reader and watcher threads. It only moves bytes and lifecycle events between the PTY process and a connector listener; parser, core, cursor, attribute, and input-encoder behavior are owned by terminal-session and lower layers. Normal closure follows both process exit and delivery of stdout through EOF. Local close cancels pending reads instead of draining; read or byte-listener failure reports the original error and releases the process and both streams once. Listener callbacks may close this connector reentrantly.

Parameters

process

the underlying PTY process.

readBufferSize

size of the read buffer in bytes.

readerThreadName

name for the daemon PTY stdout reader thread.

watcherThreadName

name for the daemon process exit watcher thread.

outputDrained

lifecycle latch completed by the reader and awaited after process exit.

Constructors

Link copied to clipboard
constructor(process: PtyProcess, readBufferSize: Int = DEFAULT_READ_BUFFER_SIZE, readerThreadName: String = DEFAULT_READER_THREAD_NAME, watcherThreadName: String = DEFAULT_WATCHER_THREAD_NAME)

Creates a connector for a raw PTY4J process.

Properties

Link copied to clipboard

Process exit code after the watcher observes process termination.

Link copied to clipboard

Original read or byte-listener exception, or null when no reader failure occurred. Exceptions after local close are treated as teardown and ignored.

Link copied to clipboard

Returns true while the underlying PTY process reports it is alive.

Functions

Link copied to clipboard
open override fun close()
Link copied to clipboard
open override fun foregroundProcessName(): String?

Reads the Unix foreground process-group leader or uses the newest live descendant on Windows. The Windows result is a heuristic and may identify a background child. Returns only a basename, or null on closure/unavailable metadata; applications inside SSH or WSL are not inspected.

Link copied to clipboard
open override fun resize(columns: Int, rows: Int)
Link copied to clipboard
open override fun start(listener: TerminalConnectorListener)
Link copied to clipboard
fun waitFor(): Int

Waits for the child process to exit and returns its exit code. This does not wait for output delivery; TerminalConnectorListener.onClosed is the completion boundary for drained output.

Link copied to clipboard
open override fun write(bytes: ByteArray, offset: Int, length: Int)