refactor: replace PID cleanup with loop (#1579)

This commit is contained in:
Gamal Moussa 2025-11-20 09:49:24 +02:00 committed by GitHub
parent ad6f87046a
commit bdb0488151
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -76,6 +76,12 @@ finish() {
local pid
local cnt=0
local reason=$1
local pids=(
"/var/run/tpm.pid"
"/var/run/wsdd.pid"
"/var/run/samba/nmbd.pid"
"/var/run/samba/smbd.pid"
)
touch "$QEMU_END"
@ -114,21 +120,12 @@ finish() {
fi
fi
pid="/var/run/tpm.pid"
[ -s "$pid" ] && pKill "$(<"$pid")"
rm -f "$pid"
pid="/var/run/wsdd.pid"
[ -s "$pid" ] && pKill "$(<"$pid")"
rm -f "$pid"
pid="/var/run/samba/nmbd.pid"
[ -s "$pid" ] && pKill "$(<"$pid")"
rm -f "$pid"
pid="/var/run/samba/smbd.pid"
[ -s "$pid" ] && pKill "$(<"$pid")"
rm -f "$pid"
for pid in "${pids[@]}"; do
if [[ -s "$pid" ]]; then
pKill "$(cat "$pid")"
fi
rm -f "$pid"
done
closeNetwork