refactor: improve kill VM logic by using VM_PID
This commit is contained in:
parent
58599a98ab
commit
27ca4a27f0
17
quickemu
17
quickemu
|
@ -1962,21 +1962,20 @@ fi
|
|||
|
||||
if [ ${KILL_VM} -eq 1 ]; then
|
||||
echo "Killing ${VMNAME}"
|
||||
if [ -r "${VMDIR}/${VMNAME}.pid" ]; then
|
||||
VM_PID=$(head -c50 "${VMDIR}/${VMNAME}.pid")
|
||||
if [ -z "${VM_PID}" ]; then
|
||||
echo " - ${VMNAME} is not running."
|
||||
rm -f "${VMDIR}/${VMNAME}.pid"
|
||||
elif [ -n "${VM_PID}" ]; then
|
||||
if kill -9 "${VM_PID}" > /dev/null 2>&1; then
|
||||
echo " - ${VMNAME} (${VM_PID}) killed."
|
||||
rm -f "${VMDIR}/${VMNAME}.pid"
|
||||
exit
|
||||
else
|
||||
echo " - ERROR! ${VMNAME} with PID ${VM_PID} was not killed."
|
||||
rm -f "${VMDIR}/${VMNAME}.pid"
|
||||
exit 1
|
||||
echo " - ${VMNAME} (${VM_PID}) was not killed."
|
||||
fi
|
||||
else
|
||||
echo " - ERROR! Could not read ${VMDIR}/${VMNAME}.pid."
|
||||
exit 1
|
||||
elif [ ! -r "${VMDIR}/${VMNAME}.pid" ]; then
|
||||
echo " - ${VMNAME} has no ${VMDIR}/${VMNAME}.pid"
|
||||
fi
|
||||
exit
|
||||
fi
|
||||
|
||||
if [ ${DELETE_DISK} -eq 1 ]; then
|
||||
|
|
Loading…
Reference in New Issue