rsyslog/tests/testsuites/omprog-output-capture-bin.sh
Joan Sala 4a54c23dc0 omprog: improve child process output capture/redirection
Capture program output using a pipe shared with all child processes,
and write to the file using a dedicated thread. Ensures lines emitted
by the child processes will not be intermingled in the output file if
the lines are less than PIPE_BUF chars long and are written in line-
buffered mode.

Reopen output file on HUP, to support external rotation of the file.

New setting 'fileCreateMode' as in omfile.

With these improvements the 'output' setting should now be usable for
production (it was originally intended only for debugging).

Redirect stdout/stderr of child process to /dev/null when not captured.
Closes #2787

Minor: simplify some test code: 'wait-startup' not needed after
'startup', 'wait-queueempty' not needed before 'shutdown_when_empty'.
2018-09-02 10:35:59 +02:00

17 lines
305 B
Bash
Executable File

#!/bin/bash
echo "[stdout] Starting"
>&2 echo "[stderr] Starting"
read log_line
while [[ -n "$log_line" ]]; do
echo "[stdout] Received $log_line"
>&2 echo "[stderr] Received $log_line"
read log_line
done
echo "[stdout] Terminating normally"
>&2 echo "[stderr] Terminating normally"
exit 0