mirror of
https://github.com/vdsm/virtual-dsm.git
synced 2026-11-11 00:40:07 +01:00
fix: Prevent race when reading PID files (#1342)
This commit is contained in:
1 parent
2b27f32cd4
commit
3c7c3ca1b1
1 file changed
+4
-3
+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