Version 0.3.1 - Open input for read-write to avoid blocking.

This commit is contained in:
Darren 'Tadgy' Austin 2020-06-15 04:11:58 +01:00
commit 3e5a3e0e85

View file

@ -8,7 +8,7 @@
# Script details. # Script details.
NAME="${0##*/}" NAME="${0##*/}"
VERSION="0.3.0" VERSION="0.3.1"
# Functions. # Functions.
@ -545,7 +545,8 @@ TEMPLATE="$2"
[[ -n "$RUNAS_USER" ]] && { exec -a "su" /bin/su - "$RUNAS_USER" -- "$0" "${ORIG_ARGS[@]}" "$BASEDIR" "$TEMPLATE" || die "failed to exec to change user"; } [[ -n "$RUNAS_USER" ]] && { exec -a "su" /bin/su - "$RUNAS_USER" -- "$0" "${ORIG_ARGS[@]}" "$BASEDIR" "$TEMPLATE" || die "failed to exec to change user"; }
# If input is to be a pipe/FIFO, open it. # If input is to be a pipe/FIFO, open it.
[[ -n "$INPUT" ]] && { exec {INPUTFD}<"$INPUT" || die "failed to open pipe/FIFO for reading: $INPUT"; } # Note: The fifo must be opened in read-write mode in order to avoid blocking.
[[ -n "$INPUT" ]] && { exec {INPUTFD}<>"$INPUT" || die "failed to open pipe/FIFO for reading: $INPUT"; }
# Main loop # Main loop
while :; do while :; do
@ -557,8 +558,8 @@ while :; do
start_compression_jobs start_compression_jobs
# Read the log line, but timeout at the top of the next second if nothing is read. # Read the log line, but timeout at the top of the next second if nothing is read.
# Note: The second $(...) expansion should *not* be quoted in this instance, # Note: The second $(...) expansion should *not* be quoted in this instance, and
# and the space between $( and (( is necessary to quiet shellcheck. # the space between $( and (( is necessary to quiet shellcheck.
# shellcheck disable=SC2046 # shellcheck disable=SC2046
read -r -t "0.$(( 999999999 - 10#$(date +%N) ))" -u "$INPUTFD" $( (( FLAGS[raw] == 0 )) && printf "%s" "LOG_VHOST") LOG_DATA read -r -t "0.$(( 999999999 - 10#$(date +%N) ))" -u "$INPUTFD" $( (( FLAGS[raw] == 0 )) && printf "%s" "LOG_VHOST") LOG_DATA
ERR="$?" ERR="$?"