Unreleased APIs from PR #2. Not in 0.2.1. Stable 0.2.1 reference.
LOOM Unreleased (PR #2) / SUPPORTING WEFT TYPES
PseudoTerminalProcess
A child process with a controlling pseudo-terminal and bounded, nonblocking I/O.
Use one serial execution context. Drain output and poll exit status independently: a child may exit before its final output is read. Closing terminates a running child group and reaps it off the caller's execution context.
Defined by weft, with no loom typealias. Add the weft product to your target and use import weft when referring to this type by name.
Standard inherited Swift protocol operations such as synthesized equality and OptionSet set operations are not repeated. The public declarations below are extracted from the exact source revision listed in the coverage manifest.
Members on this page
Feature guides and release status
PseudoTerminalProcess
final class PseudoTerminalProcessA child process with a controlling pseudo-terminal and bounded, nonblocking I/O.
Use one serial execution context. Drain output and poll exit status independently: a child may exit before its final output is read. Closing terminates a running child group and reaps it off the caller's execution context.
Source · PseudoTerminalProcess.swift:17processIdentifier
let processIdentifier: Int32A public field of this type. Its value type and mutability are shown in the declaration.
Source · PseudoTerminalProcess.swift:18init(executable:arguments:environment:size:)
init(executable: URL, arguments: [String] = [], environment: [String : String]? = nil, size: Rect = Rect(width: 80, height: 24)) throwsCreates a value with the supplied arguments. Default arguments are shown in the declaration.
Parameters (4)
executable- Argument type and any default are shown in the declaration; see the behavior notes above.
arguments- Argument type and any default are shown in the declaration; see the behavior notes above.
environment- Environment hints used to infer optional terminal features.
size- Argument type and any default are shown in the declaration; see the behavior notes above.
read(timeoutMilliseconds:)
func read(timeoutMilliseconds: Int = 0) throws -> Data?Returns at most 8 KiB, empty data when not ready, or nil on terminal EOF.
Zero polls immediately; -1 waits for readiness. No output bytes are decoded.
Parameters (1)
timeoutMilliseconds- Poll timeout: 0 is nonblocking, -1 waits indefinitely.
Returns Data?.
write(_:)
func write(_ bytes: Data) throws -> IntWrites at most 8 KiB; zero means backpressure or that the child terminal is still starting.
Retain and retry the unwritten suffix. This call never waits for writable space.
Parameters (1)
bytes- Input bytes to decode incrementally.
Returns Int.
waitForWritable(timeoutMilliseconds:)
func waitForWritable(timeoutMilliseconds: Int = 16) throws -> BoolWaits for writable space without consuming child output or changing terminal modes.
Returns false on timeout or interruption so the caller can service signals and resize.
Parameters (1)
timeoutMilliseconds- Poll timeout: 0 is nonblocking, -1 waits indefinitely.
Returns Bool.
resize(_:)
func resize(_ size: Rect) throwsUpdates the child terminal dimensions and lets the kernel notify its foreground group.
Parameters (1)
size- Argument type and any default are shown in the declaration; see the behavior notes above.
pollExitStatus()
func pollExitStatus() throws -> Int32?Returns nil while running, a normal exit code, or 128 plus its terminating signal.
This also drains final output before reaping. Consume read() while polling:
status can be deferred until the bounded output queue has room.
Returns Int32?.
terminate(signal:)
func terminate(signal: Int32 = 15) throwsSends a signal to the owned child session's process group while its leader is unreaped.
Parameters (1)
signal- Argument type and any default are shown in the declaration; see the behavior notes above.
close()
func close()Releases the PTY exactly once and terminates any still-running owned child group.
Source · PseudoTerminalProcess.swift:140