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)
.output { timeoutMillis = 1_500 }
assertEquals(5, out.processInfo.exitCode)
e.g. (Executable file)
val p = 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"))
.spawn()
Parameters
The command to run. On Native Linux
, macOS
and iOS
, if command is a relative file path or program name (e.g. ping
) then posix_spawnp
is utilized. If it is an absolute file path (e.g. /usr/bin/ping
), then posix_spawn
is utilized.
Constructors
Functions
Add multiple arguments
Add a single argument
Changes the working directory of the spawned process.
Set the Signal to use when Process.destroy is called.
Configures the detached
option for spawn
.
Modify the environment via lambda
Set/overwrite an environment variable
Set a ProcessException.Handler to manage internal Process errors for spawned processes.
Blocks the current thread until Process completion, Output.Options.Builder.timeoutMillis is exceeded, or Output.Options.Builder.maxBuffer is exceeded.
Configures the shell
option for spawn
and spawnSync
Configures the shell
option for spawn
and spawnSync
.
Modify the standard error output destination
Modify the standard input source
Modify the standard output destination
Configures the windowsHide
option for spawn
and spawnSync
Configures the windowsVerbatimArguments
option for spawn
and spawnSync