mirror of
https://github.com/vdsm/virtual-dsm.git
synced 2026-08-28 11:56:03 +00:00
fix: Prevent race when reading PID files (#1342)
This commit is contained in:
+4
-3
@@ -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=""
|
||||
|
||||
Reference in New Issue
Block a user