Builder
Creates a new Process.
e.g. (Shell commands on a Unix system)
val out = Process.Builder("sh")
.args("-c")
.args("sleep 1; exit 5")
.destroySignal(Signal.SIGKILL)
.stdin(Stdio.Null)
// Synchronous API (All platforms)
.createOutput { timeoutMillis = 1_500 }
assertEquals(5, out.processInfo.exitCode)e.g. (Executable file)
val b = Process.Builder(myExecutableFile)
.args("--some-flag")
.args("someValue")
.args("--another-flag", "anotherValue")
.environment {
remove("HOME")
// ...
}
.stdin(Stdio.Null)
.stdout(Stdio.File.of("logs/myExecutable.log", append = true))
.stderr(Stdio.File.of("logs/myExecutable.err"))
// Synchronous API (Jvm/Native)
b.createProcess().use { p ->
// ...
}
// Asynchronous API (All platforms)
myScope.launch {
b.createProcessAsync().use { p ->
// ...
}
}Constructors
Properties
Functions
Add a single argument.
Add multiple arguments.
DEFAULT: Dispatchers.IO (Jvm/Native), Dispatchers.Default (Js/WasmJs)
Changes the working directory of the spawned process.
Blocks the current thread until Process completion, Output.Options.Builder.timeoutMillis is exceeded, or Output.Options.Builder.maxBuffer is exceeded.
Creates the Process asynchronously using the configured async context and suspends until its completion, Output.Options.Builder.timeoutMillis is exceeded, or Output.Options.Builder.maxBuffer is exceeded.
DEFAULT: Signal.SIGTERM
DEFAULT: false
Configure the process' environment via lambda
Configure/overwrite an environment variable
DEFAULT: null (i.e. use ProcessException.Handler.IGNORE)
DEFAULT: false
DEFAULT: Stdio.Pipe
DEFAULT: Stdio.Pipe
DEFAULT: Stdio.Pipe
DEFAULT: true
DEFAULT: true
DEFAULT: false