Wrap any processx::process object into a deferred value. The process is created by a generator function.
external_process(process_generator, error_on_status = TRUE, ...)
Function that returns a processx::process object. See details below about the current requirements for the returned process.
Whether to fail if the process terminates with a non-zero exit status.
Extra arguments, passed to process_generator
.
Deferred object.
Current requirements for process_generator
:
It must take a ...
argument, and pass it to
processx::process$new()
.
It must use the poll_connection = TRUE
argument.
These requirements might be relaxed in the future.
If you want to obtain the standard output and/or error of the
process, then process_generator
must redirect them to files.
If you want to discard them, process_generator
can set them to
NULL
.
process_generator
should not use pipes ("|"
) for the standard
output or error, because the process will stop running if the
pipe buffer gets full. We currently never read out the pipe buffer.
if (FALSE) { # \dontrun{
lsgen <- function(dir = ".", ...) {
processx::process$new(
"ls",
dir,
poll_connection = TRUE,
stdout = tempfile(),
stderr = tempfile(),
...
)
}
afun <- function() {
external_process(lsgen)
}
synchronise(afun())
} # }