process.stderr_read
process.stderr_read
Function
Reads the text currently available on stderr of the started child process.
Syntax
process(program).child().stderr_read()
Parameters
No parameters.
Return value
| Type | Description |
|---|---|
| String | Returns the stderr text read this time; the first read of the real zero-byte output of the child process returns ''. |
| Empty | The child process has not been started, there is no stderr pipe, there is no new data within the timeout, or the pipe has been closed and the remaining data has been read. |
Example
if BT.OS == 'windows' { cmd = process('cmd').args(['/C', 'echo BT_ERR 1>&2']).child() } else { cmd = process('sh').args(['-c', 'printf BT_ERR >&2']).child() } cmd.wait() result = cmd.stderr_read().trim() // Output: BT_ERR print result
Notes
- stderr_read() returns at most BT_PROCESS_PIPE_READ_CHUNK bytes; it can be called repeatedly when more output needs to be read.
- stderr and stdout calculate the unread buffer limit respectively.
- The default BT_PROCESS_PIPE_LIMIT is 1048576 bytes, BT_PROCESS_PIPE_READ_CHUNK is 8192 bytes, and BT_PROCESS_PIPE_TIMEOUT_MS is 100 milliseconds; a single Process can use pipe_limit(bytes) to override the unread buffer limit.
- BT_PROCESS_PIPE_LIMIT limits the current unread buffer and does not limit the historical cumulative output; as long as reading continues, the long-term error stream can exceed 1MB of total output.