mirror of
https://github.com/rsyslog/rsyslog.git
synced 2025-12-16 12:10:46 +01:00
Add new global setting 'reportChildProcessExits' with possible values 'none|errors|all' (default 'errors'), and new global function 'glblReportChildProcessExit' to report the exit status of a child process according to the setting. Invoke the report function whenever rsyslog reaps a child, namely in: - rsyslogd.c (SIGCHLD signal handler) - omprog - mmexternal - srutils.c (execProg function, invoked from stream.c and omshell) Remove redundant "reaped by main loop" info log in omprog. Promote debug message in mmexternal indicating that the child has terminated prematurely to a warning log, like in omprog. Closes #3281
50 lines
1.2 KiB
Bash
Executable File
50 lines
1.2 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
outfile=$RSYSLOG_OUT_LOG
|
|
terminate=false
|
|
|
|
function handle_sigusr1 {
|
|
echo "Received SIGUSR1, will terminate after the next message" >> $outfile
|
|
>&2 echo "[stderr] Received SIGUSR1, will terminate after the next message"
|
|
terminate=true
|
|
}
|
|
trap "handle_sigusr1" SIGUSR1
|
|
|
|
function handle_sigterm {
|
|
echo "Received SIGTERM, terminating" >> $outfile
|
|
>&2 echo "[stderr] Received SIGTERM, terminating"
|
|
exit 1
|
|
}
|
|
trap "handle_sigterm" SIGTERM
|
|
|
|
echo "Starting" >> $outfile
|
|
|
|
# Write also to stderr (useful for testing the 'output' setting)
|
|
>&2 echo "[stderr] Starting"
|
|
|
|
# Tell rsyslog we are ready to start processing messages
|
|
echo "OK"
|
|
|
|
read log_line
|
|
while [[ -n "$log_line" ]]; do
|
|
echo "Received $log_line" >> $outfile
|
|
>&2 echo "[stderr] Received $log_line"
|
|
|
|
if [[ $terminate == true ]]; then
|
|
# Terminate prematurely by closing pipe, without confirming the message
|
|
echo "Terminating without confirming the last message" >> $outfile
|
|
>&2 echo "[stderr] Terminating without confirming the last message"
|
|
exit 0
|
|
fi
|
|
|
|
# Tell rsyslog we are ready to process the next message
|
|
echo "OK"
|
|
|
|
read log_line
|
|
done
|
|
|
|
echo "Terminating normally" >> $outfile
|
|
>&2 echo "[stderr] Terminating normally"
|
|
|
|
exit 0
|