public class ProcessChannel implements AutoClosable
Persistent binary stdin/stdout of an external process, without a terminal or implicit shell. Intended for protocols such as language servers. Standard error is drained independently into a bounded 64 KiB tail; it never contaminates stdout or blocks the child. Close terminates the owned process group/job, interrupts outstanding transfers and releases OS resources. A GC finalizer provides fallback cleanup; deterministic close is preferred.
import klyn.process
try channel = ProcessChannel(["clangd", "--log=error"]):
buffer = Byte[8192]
count = channel.readInto(buffer, timeout=100ul)
# -1 means timeout, 0 means EOF, positive counts are raw protocol bytes.| Modifier and Type | Member | Description |
|---|---|---|
| public readonly property | PIDPID as UInt |
No summary. |
| public readonly property | errorTexterrorText as String |
Most recent stderr bytes decoded as UTF-8, up to 64 KiB. |
| public readonly property | exitCodeexitCode as Long |
Exit status of an exited direct child, available until close. |
| public readonly property | isRunningisRunning as Boolean |
Whether the direct child is still running; does not wait for its exit. |
| Modifier and Type | Member | Description |
|---|---|---|
| public | ProcessChannelProcessChannel(notnull commandLine as List<String>, cwd as String = "") |
Starts the executable with separate arguments and an optional directory. |
| Modifier and Type | Member | Description |
|---|---|---|
| public | closeclose() as Void |
Terminates the owned child tree and interrupts outstanding reads/writes. |
| public | closeInputcloseInput() as Void |
Sends EOF to stdin while leaving stdout readable. |
| public | readInto | Reads raw stdout into existing contiguous byte storage without boxing. |
| public | writeBytes | Writes the entire byte range to stdin, preserving NUL and line endings. |