readwrite: Communicating with a Child Process

Description Usage Arguments Format Details Value

Description

process_read() reads data from one of the child process' streams, standard output or standard error output, and returns it as a character vector.

process_write() writes data into child's standard input stream.

process_close_input() closes the write end of the pipe whose read end is the standard input stream of the child process. This is a standard way to gracefully request the child process to exit.

PIPE_STDOUT: read from child's standard output.

PIPE_STDERR: read from child's standard error output.

PIPE_BOTH: read from both child's output streams: standard output and standard error output.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12

Arguments

handle

Process handle obtained from spawn_process.

pipe

Output stream identifier: PIPE_STDOUT, PIPE_STDERR or PIPE_BOTH.

timeout

Optional timeout in milliseconds.

flush

If there is any data within the given timeout try again with timeout=0 until C buffer is empty.

message

Input for the child process.

Format

PIPE_STDOUT, PIPE_STDERR and PIPE_BOTH are single character values.

Details

If flush=TRUE in process_read() then the invocation of the underlying read() system-call will be repeated until the pipe buffer is empty.

If pipe is set to either PIPE_STDOUT or PIPE_STDERR, the returned value is a single list with a single key, stdout or stderr, respectively. If pipe is set to PIPE_BOTH the returned list contains both keys. Values in the list are character vectors of 0 or more elements, lines read from the respective output stream of the child process.

For details on timeout see terminating.

Value

process_read returns a list containing either of or both keys: stdout and stderr; the value is in both cases a character vector which contains lines of child's output.

process_write returns the number of characters written.


subprocess documentation built on May 29, 2017, 11:02 a.m.