fix: Verify files are not empty (#383)

This commit is contained in:
Kroese 2024-04-16 16:22:28 +02:00 committed by GitHub
parent 2a98081549
commit 8a5f233e34
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 29 additions and 26 deletions

View file

@ -25,7 +25,7 @@ _trap() {
ready() {
[ -f "$STORAGE/windows.boot" ] && return 0
[ ! -f "$QEMU_PTY" ] && return 1
[ ! -s "$QEMU_PTY" ] && return 1
if [ -f "$STORAGE/windows.old" ]; then
local last
@ -52,7 +52,7 @@ finish() {
touch "$QEMU_END"
if [ -f "$QEMU_PID" ]; then
if [ -s "$QEMU_PID" ]; then
pid=$(<"$QEMU_PID")
error "Forcefully terminating Windows, reason: $reason..."
@ -61,7 +61,7 @@ finish() {
while isAlive "$pid"; do
sleep 1
# Workaround for zombie pid
[ ! -f "$QEMU_PID" ] && break
[ ! -s "$QEMU_PID" ] && break
done
fi
@ -74,7 +74,7 @@ finish() {
fi
pid="/var/run/tpm.pid"
[ -f "$pid" ] && pKill "$(<"$pid")"
[ -s "$pid" ] && pKill "$(<"$pid")"
fKill "wsdd"
fKill "smbd"
@ -91,7 +91,7 @@ terminal() {
local dev=""
if [ -f "$QEMU_OUT" ]; then
if [ -s "$QEMU_OUT" ]; then
local msg
msg=$(<"$QEMU_OUT")
@ -139,7 +139,7 @@ _graceful_shutdown() {
touch "$QEMU_END"
info "Received $1, sending ACPI shutdown signal..."
if [ ! -f "$QEMU_PID" ]; then
if [ ! -s "$QEMU_PID" ]; then
error "QEMU PID file does not exist?"
finish "$code" && return "$code"
fi
@ -168,7 +168,7 @@ _graceful_shutdown() {
! isAlive "$pid" && break
# Workaround for zombie pid
[ ! -f "$QEMU_PID" ] && break
[ ! -s "$QEMU_PID" ] && break
info "Waiting for Windows to shutdown... ($cnt/$QEMU_TIMEOUT)"