From 66de6e7066525fb58d366272b2004646769fe081 Mon Sep 17 00:00:00 2001 From: Kroese Date: Tue, 16 Apr 2024 15:52:15 +0200 Subject: [PATCH] fix: Verify files are not empty --- src/power.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/power.sh b/src/power.sh index 5375e65..cc28f8d 100644 --- a/src/power.sh +++ b/src/power.sh @@ -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)"