diff options
author | siegmund-heiss-ich <119589995+siegmund-heiss-ich@users.noreply.github.com> | 2023-05-28 22:54:30 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-28 22:54:30 +0200 |
commit | 7e0b4bd538cbd4d9a7aff7f1936b781bb036998a (patch) | |
tree | 6d09f4360d6cc1fb978445ecbd591b2dd86dcbe6 /distribution/macos | |
parent | 378080eb8721f7ef652f7a546efd00d0b821c80d (diff) |
Improve macOS updater (#5064)1.1.831
* Fix macOS Updater (once again)
* Also fix my brain's issues
* Move set -e that lsof doesn't trigger exit 1
* Resolve yesterdays brain malfunction 2
* Revert "Move set -e that lsof doesn't trigger exit 1"
This reverts commit 589a630610fff26f6a549d82c73be61b74187327.
* Also check if PID exists
* Remove lsof and instead check for running processes
* Remove empty lines
* Increase max iterations
* Address feedback
* Remove obsolete check for child processes
* Update comments
* Update comments
* I swear this is the last commit
* lsof + ps check
Diffstat (limited to 'distribution/macos')
-rwxr-xr-x | distribution/macos/updater.sh | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/distribution/macos/updater.sh b/distribution/macos/updater.sh index 0854d434..4d7dcdf2 100755 --- a/distribution/macos/updater.sh +++ b/distribution/macos/updater.sh @@ -25,14 +25,27 @@ error_handler() { exit 1 } -# 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 - trap 'error_handler ${LINENO}' ERR +# Wait for Ryujinx to exit. +# If the main process is still acitve, we wait for 1 second and check it again. +# After the fifth time checking, this script exits with status 1. + +attempt=0 +while true; do + if lsof -p $APP_PID +r 1 &>/dev/null || ps -p "$APP_PID" &>/dev/null; then + if [ "$attempt" -eq 4 ]; then + exit 1 + fi + sleep 1 + else + break + fi + (( attempt++ )) +done + +sleep 1 + # Now replace and reopen. rm -rf "$INSTALL_DIRECTORY" mv "$NEW_APP_DIRECTORY" "$INSTALL_DIRECTORY" |