ProcessChannel
classin packageklyn.process
public class ProcessChannel implements AutoClosable
ProcessChannel
All Implemented Interfaces: 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.

Example
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.
Properties
Modifier and Type Member Description
public readonly property PID
PID as UInt
No summary.
public readonly property errorText
errorText as String
Most recent stderr bytes decoded as UTF-8, up to 64 KiB.
public readonly property exitCode
exitCode as Long
Exit status of an exited direct child, available until close.
public readonly property isRunning
isRunning as Boolean
Whether the direct child is still running; does not wait for its exit.
Constructors
Modifier and Type Member Description
public ProcessChannel
ProcessChannel(notnull commandLine as List<String>, cwd as String = "")
Starts the executable with separate arguments and an optional directory.
Methods
Modifier and Type Member Description
public close
close() as Void
Terminates the owned child tree and interrupts outstanding reads/writes.
public closeInput
closeInput() as Void
Sends EOF to stdin while leaving stdout readable.
public readInto
readInto(notnull buffer as Byte[], offset as Long = 0l, length as Long = -1l, timeout as ULong = 0ul) as Long
Reads raw stdout into existing contiguous byte storage without boxing.
public writeBytes
writeBytes(notnull buffer as Byte[], offset as Long = 0l, length as Long = -1l, timeout as ULong = 30000ul) as Void
Writes the entire byte range to stdin, preserving NUL and line endings.
Inherited Methods
methodInherited Methods from AutoClosable: close