From 4a477fb2b60faeb075bc83dabfbc57c4a85b1fc1 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Tue, 10 Sep 2019 15:27:04 +0200 Subject: [run-virt] Add window manager respawn loop Apparently on certain hw combinations openbox might crash while VMware is initializing. Try to restart it right away... --- .../run-virt-includes/start_windowmanager.inc | 49 ++++++++++++++++------ 1 file changed, 37 insertions(+), 12 deletions(-) diff --git a/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/start_windowmanager.inc b/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/start_windowmanager.inc index 749991bb..85b4a96a 100644 --- a/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/start_windowmanager.inc +++ b/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/start_windowmanager.inc @@ -23,21 +23,46 @@ start_wm() { # start RUNVIRT_DM determined above writelog "Starting ${RUNVIRT_DM}." - if [ "${RUNVIRT_DM}" = "fvwm2" ]; then + declare -a OPTS= + case "$RUNVIRT_DM" in + openbox|kwin|xfwm4|metacity) + OPTS+=( "--replace" ) + ;; + fvwm2) # fvwm2 is not even in the minilinux, so this might be obsolete... - echo "EdgeScroll 0 0" > ${TMPDIR}/fvwm - fvwm2 -f ${TMPDIR}/fvwm >/dev/null 2>&1 & - else - ${RUNVIRT_DM} >/dev/null 2>&1 & - fi - local RUNVIRT_DM_PID="$$" - if ! kill -0 ${RUNVIRT_DM_PID} ; then - # not fatal, just warn user - notify_user "$RUNVIRT_VM stoppte unerwartet." - return 1 - fi + echo "EdgeScroll 0 0" > "${TMPDIR}/fvwm" + OPTS+=( "-replace" "-f" "${TMPDIR}/fvwm" ) + ;; + esac + { + dc=0 + while true; do + s="$( date +%s )" + "${RUNVIRT_DM}" "${OPTS[@]}" &> /dev/null + ret="$?" + e="$( date +%s )" + duration="$(( e - s ))" + case "$ret" in + 0|129|130|143) exit 0 ;; + esac + if [ "$duration" -ge 3 ]; then + dc=0 + elif [ "$(( dc++ ))" -gt 5 ]; then + notify_user "$RUNVIRT_DM crasht immer wieder." + exit 1 + fi + done + } & + declare -rg RUNVIRT_DM_PID="$!" + add_cleanup stop_wm return 0 } +stop_wm() { + kill "$RUNVIRT_DM_PID" + usleep 500000 + kill -9 "$RUNVIRT_DM_PID" +} + ## MAIN ## call_post_source start_wm -- cgit v1.2.3-55-g7522