fix: Prevent race when reading PID files (#1342)

This commit is contained in:
Kroese
2026-07-28 14:22:08 +02:00
committed by GitHub
parent 2b27f32cd4
commit 3c7c3ca1b1
+4 -3
View File
@@ -12,9 +12,10 @@ readPidFile() {
local -n _pid="$1"
_pid=""
[ -s "$2" ] || return 1
_pid=$(<"$2")
if ! _pid=$(cat -- "$2" 2>/dev/null); then
_pid=""
return 1
fi
if [[ ! "$_pid" =~ ^[1-9][0-9]*$ ]]; then
_pid=""