Communicating with a Child Process

Share:

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.

Usage

1
2
3
4
process_read(handle, pipe = "stdout", timeout = TIMEOUT_IMMEDIATE,
  flush = TRUE)

process_write(handle, message)

Arguments

handle

Process handle obtained from spawn_process.

pipe

Output stream name, "stdout" or "stderr".

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.

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.

For details on timeout see terminating.

Value

process_read returns a character vector which contains lines of child's output.

process_write returns the number of characters written.