From 90fff5f1bd9e20d86f5945c353e4662de5694344 Mon Sep 17 00:00:00 2001 From: Steven Chamberlain Date: Thu, 13 Nov 2014 13:41:27 +0000 Subject: g-i: try to stop qemu with SIGINT before SIGKILL --- bin/g-i-installation.sh | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/bin/g-i-installation.sh b/bin/g-i-installation.sh index 60223bdf..45bc0a87 100644 --- a/bin/g-i-installation.sh +++ b/bin/g-i-installation.sh @@ -109,7 +109,16 @@ cleanup_all() { # # kill qemu # - sudo kill -9 $(ps fax | grep [q]emu-system | grep "vnc=$DISPLAY " 2>/dev/null | awk '{print $1}') || true + # use SIGINT for 10 seconds to encourage graceful shutdown + for i in $(seq 1 10); do + QEMU_PID=$(ps fax | grep [q]emu-system | grep "vnc=$DISPLAY " 2>/dev/null | awk '{print $1}') + [ -z "$QEMU_PID" ] && break + sudo kill -INT $QEMU_PID + sleep 1 + done + # force exit with SIGKILL if still running now + QEMU_PID=$(ps fax | grep [q]emu-system | grep "vnc=$DISPLAY " 2>/dev/null | awk '{print $1}') + [ -z "$QEMU_PID" ] || sudo kill -KILL $QEMU_PID sleep 0.3s # # save logs if there are any -- cgit v1.2.3-70-g09d2