]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
util: health-check.sh - Use a cleaner way to kill sleep
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Fri, 31 Oct 2025 12:44:18 +0000 (14:44 +0200)
committertimo.sirainen <timo.sirainen@open-xchange.com>
Fri, 31 Oct 2025 21:26:31 +0000 (21:26 +0000)
With the 6ee85b80857d241622a349aac47d51b70b27cc46 approach it introduced
errors like:

Error: ... Terminated { sleep $timeout; kill -3 $$ 2> /dev/null; }

src/util/health-check.sh

index 99f9299bec1160a985de8fa3888dce2c59916bf7..36702a7c7544f3820c3bfaa298465ebc6d7527e7 100755 (executable)
@@ -16,6 +16,8 @@ timeout=10
 
 # timeout the read via trap for POSIX shell compatibility
 trap "exit 0" QUIT
+trap 'kill $timeout_pid 2>/dev/null' EXIT INT TERM
+
 {
        sleep $timeout
        kill -3 $$ 2>/dev/null
@@ -25,9 +27,6 @@ timeout_pid=$!
 read -r input
 exit_code=$?
 
-# Kill the background sleep process
-kill $timeout_pid 2>/dev/null
-
 cleaned_input=$(echo ${input} | sed "s/[^a-zA-Z0-9]//g")
 
 if [ ${exit_code} -eq 0 ] && [ "${cleaned_input}" = "PING" ];then