From b37bc30549b08d548bbebaa7c5538705fb090fee Mon Sep 17 00:00:00 2001 From: Thomas Oettli Date: Mon, 4 Nov 2024 10:27:42 +0100 Subject: [PATCH] just handle rc of wait instead of comparing bash version --- snmpd-oid-daemon.sh | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/snmpd-oid-daemon.sh b/snmpd-oid-daemon.sh index 6bb00c5..18fbb40 100755 --- a/snmpd-oid-daemon.sh +++ b/snmpd-oid-daemon.sh @@ -610,12 +610,10 @@ while :; do ps -p $pid >/dev/null && kill -SIGKILL $pid rc=137 else - if (( ${BASH_VERSINFO[0]} >= 5 )) && (( ${BASH_VERSINFO[1]} >= 1 )); then - wait $pid - rc=$? - else - rc=0 - fi + wait $pid &>/dev/null + rc=$? + # the wait function in older Bash versions always returns 127 if the sub-proc already exited + (( rc == 127 )) && rc=0 fi echo "gather: $func (PID $pid, FD $fd) exited with rc = $rc" >&$DEBUGLOG if (( rc == 0 )) && [ -n "$data" ]; then