OutputFeed
A callback for obtaining stdout and stderr output.
NOTE: Jvm and Native onOutput is invoked from a background thread (either the stdout thread or the stderr thread, whichever is being observed by the OutputFeed). It is ill-advised to attach the same OutputFeed to both stdout and stderr.
NOTE: Any exceptions that onOutput throws will be delegated to ProcessException.Handler. If it is re-thrown by the ProcessException.Handler, the Process will be terminated, and all OutputFeed for that I/O stream will be ejected immediately.
e.g.
val p = builder.spawn()
.stdoutFeed { line ->
println(line ?: "--STDOUT EOS--")
}.stderrFeed(
// attach multiple at once
OutputFeed { line ->
println(line ?: "--STDERR EOS--")
},
OutputFeed { line ->
// do something
}
)
p.waitFor(500.milliseconds)
val exitCode = p.destroy()
.stdoutWaiter()
.awaitStop()
.stderrWaiter()
.awaitStop()
.waitFor()See also
Types
Helper class which Process implements that handles everything regarding dispatching of stdout and stderr output to attached OutputFeed.
A helper to wait for stdout and stderr asynchronous output to stop after Process.destroy has been called.
Functions
A line of output from stdout or stderr (whichever this OutputFeed has been attached to).