mirror of
https://github.com/vdsm/virtual-dsm.git
synced 2026-08-28 11:56:03 +00:00
fix: Avoid shadowing PID output variables (#1337)
This commit is contained in:
+4
-16
@@ -67,18 +67,8 @@ displayReason() {
|
||||
|
||||
readQemuPid() {
|
||||
|
||||
local -n _pid="$1"
|
||||
local file
|
||||
local pid
|
||||
|
||||
for file in "$QEMU_START_PID" "$QEMU_PID"; do
|
||||
if readPidFile pid "$file"; then
|
||||
_pid="$pid"
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
|
||||
return 1
|
||||
readPidFile "$1" "$QEMU_START_PID" && return 0
|
||||
readPidFile "$1" "$QEMU_PID"
|
||||
}
|
||||
|
||||
qemuPidFile() {
|
||||
@@ -102,16 +92,14 @@ waitQemuExit() {
|
||||
|
||||
waitQemuPid() {
|
||||
|
||||
local -n _pid="$1"
|
||||
local cnt=0 value
|
||||
local cnt=0
|
||||
|
||||
while ! readQemuPid value; do
|
||||
while ! readQemuPid "$1"; do
|
||||
sleep 0.02
|
||||
cnt=$((cnt + 1))
|
||||
(( cnt >= 50 )) && return 1
|
||||
done
|
||||
|
||||
_pid="$value"
|
||||
return 0
|
||||
}
|
||||
|
||||
|
||||
+2
-4
@@ -10,13 +10,11 @@ warn () { printf "%b%s%b" "\E[1;31m❯ " "Warning: ${1:-}" "\E[0m\n" >&2; }
|
||||
readPidFile() {
|
||||
|
||||
local -n _pid="$1"
|
||||
local file="$2"
|
||||
|
||||
_pid=""
|
||||
|
||||
[ -s "$file" ] || return 1
|
||||
[ -s "$2" ] || return 1
|
||||
|
||||
_pid=$(<"$file")
|
||||
_pid=$(<"$2")
|
||||
|
||||
if [[ ! "$_pid" =~ ^[1-9][0-9]*$ ]]; then
|
||||
_pid=""
|
||||
|
||||
Reference in New Issue
Block a user