Skip to content
Kona

Processes

The process module runs shell commands and other executables with a timeout, optional working directory, and environment overrides.

val result = Process.run("sh", "-c", "echo hello")
if (result.successful()) {
println(result.output)
}
val custom = ProcessRunner(defaultTimeoutSeconds = 30)
val again = custom.run(
listOf("sh", "-c", "echo $NAME"),
workingDirectory = File("/tmp"),
env = mapOf("NAME" to "kona"),
timeoutSeconds = 5,
)
ProcessResult result = Process.run("sh", "-c", "echo hello");
boolean ok = result.successful();
String out = result.getOutput();
Field Meaning
exitCode Process exit status
output Captured stdout
errorOutput Captured stderr
successful() True when exit code is 0

If the process exceeds the timeout, Kona destroys it and throws IllegalStateException.