Learn R Programming

subprocess (version 0.8.3)

terminating: Terminating a Child Process.

Description

These functions give access to the state of the child process and to its exit status (return code).

The timeout parameter can take one of three values:

  • 0 which means no timeout

  • -1 which means "wait until there is data to read"

  • a positive integer, which is the actual timeout in milliseconds

TIMEOUT_INFINITE denotes an "infinite" timeout (that is, wait until response is available) when waiting for an operation to complete.

TIMEOUT_IMMEDIATE denotes an "immediate" timeout (in other words, no timeout) when waiting for an operation to complete.

Usage

process_wait(handle, timeout = TIMEOUT_INFINITE)

process_state(handle)

process_return_code(handle)

TIMEOUT_INFINITE

TIMEOUT_IMMEDIATE

Arguments

handle

Process handle obtained from spawn_process.

timeout

Optional timeout in milliseconds.

Value

process_wait() returns an integer exit code of the child process or NA if the child process has not exited yet. The same value can be accessed by process_return_code().

Format

An object of class integer of length 1.

Details

process_wait() checks the state of the child process by invoking the system call waitpid() or WaitForSingleObject().

process_state() refreshes the handle by calling process_wait() with no timeout and returns one of these values: "not-started". "running", "exited", "terminated".

process_return_code() gives access to the value returned also by process_wait(). It does not invoke process_wait() behind the scenes.

See Also

spawn_process(), process_read() signals()