From 5014a568beb21454c36ab7560c49c89bf6a7d3c0 Mon Sep 17 00:00:00 2001 From: siegmund-heiss-ich <119589995+siegmund-heiss-ich@users.noreply.github.com> Date: Tue, 23 May 2023 00:16:47 +0200 Subject: [PATCH] Fix macOS Updater (once again) --- distribution/macos/updater.sh | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/distribution/macos/updater.sh b/distribution/macos/updater.sh index 0854d4347f..85d4f4926f 100755 --- a/distribution/macos/updater.sh +++ b/distribution/macos/updater.sh @@ -25,13 +25,25 @@ error_handler() { exit 1 } +trap 'error_handler ${LINENO}' ERR + # Wait for Ryujinx to exit # NOTE: in case no fds are open, lsof could be returning with a process still living. -# We wait 1s and assume the process stopped after that -lsof -p $APP_PID +r 1 &>/dev/null -sleep 1 +# If the process is still acitve, we wait for 1 second and check it again. +# After the third time checking, this script exits with status 1 -trap 'error_handler ${LINENO}' ERR +attempt=0 +while [ attempt -lt 3 ]; do + if lsof -p $APP_PID +r 1 &>/dev/null; then + if [ attempt -eq 2 ]; then + exit 1 + fi + sleep 1 + else + break + fi + (( attempt++ )) +done # Now replace and reopen. rm -rf "$INSTALL_DIRECTORY"