Unverified Commit 77c164a3 authored by Kroese's avatar Kroese Committed by GitHub
Browse files

fix: Provide exitcode on shutdown (#1752)

parent f088a60e
Loading
Loading
Loading
Loading
+13 −6
Original line number Diff line number Diff line
@@ -11,11 +11,8 @@ QEMU_LOG="$QEMU_DIR/qemu.log"
QEMU_OUT="$QEMU_DIR/qemu.out"
QEMU_END="$QEMU_DIR/qemu.end"

rm -f "$QEMU_DIR/qemu.*"
touch "$QEMU_LOG"

_trap() {
  func="$1" ; shift
  local func="$1" ; shift
  for sig ; do
    trap "$func $sig" "$sig"
  done
@@ -173,15 +170,23 @@ terminal() {

_graceful_shutdown() {

  local code=$?
  local sig="$1"
  local code=0

  set +e
  case "$sig" in
    SIGTERM) code=143 ;;
    SIGINT)  code=130 ;;
    SIGHUP)  code=129 ;;
    SIGABRT) code=134 ;;
    SIGQUIT) code=131 ;;
  esac

  if [ -f "$QEMU_END" ]; then
    info "Received $1 while already shutting down..."
    return
  fi

  set +e
  touch "$QEMU_END"
  info "Received $1, sending ACPI shutdown signal..."

@@ -230,6 +235,8 @@ _graceful_shutdown() {
  finish "$code" && return "$code"
}

touch "$QEMU_LOG"

SERIAL="pty"
MONITOR="telnet:localhost:$MON_PORT,server,nowait,nodelay -daemonize -D $QEMU_LOG"