bg_process {xfun} | R Documentation |
Start a background process
Description
Start a background process using the PowerShell cmdlet
Start-Process-PassThru
on Windows or the ampersand &
on
Unix, and return the process ID.
Usage
bg_process(
command,
args = character(),
verbose = getOption("xfun.bg_process.verbose", FALSE)
)
Arguments
command , args |
The system command and its arguments. They do not need to
be quoted, since they will be quoted via |
verbose |
If |
Value
The process ID as a character string.
Note
On Windows, if PowerShell is not available, try to use
system2
(wait = FALSE)
to start the background process instead. The
process ID will be identified from the output of the command
tasklist
. This method of looking for the process ID may not be
reliable. If the search is not successful in 30 seconds, it will throw an
error (timeout). If a longer time is needed, you may set
options(xfun.bg_process.timeout)
to a larger value, but it should be very
rare that a process cannot be started in 30 seconds. When you reach the
timeout, it is more likely that the command actually failed.
See Also
proc_kill()
to kill a process.