fix: Avoid shadowing PID output variables (#1337)

This commit is contained in:
Kroese
2026-07-27 12:03:24 +02:00
committed by GitHub
parent f6871dd61b
commit efe8732e47
2 changed files with 6 additions and 20 deletions
+4 -16
View File
@@ -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
View File
@@ -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=""