mirror of
https://github.com/tw93/Mole.git
synced 2026-02-12 10:33:30 +00:00
Uninstall and stop the application is more thorough
This commit is contained in:
@@ -1201,27 +1201,56 @@ force_kill_app() {
|
|||||||
# Use executable name for precise matching, fallback to app name
|
# Use executable name for precise matching, fallback to app name
|
||||||
local match_pattern="${exec_name:-$app_name}"
|
local match_pattern="${exec_name:-$app_name}"
|
||||||
|
|
||||||
# Check if process is actually running using exact match (-x)
|
# Check if main process is running using exact match
|
||||||
if ! pgrep -x "$match_pattern" > /dev/null 2>&1; then
|
local has_main_process=false
|
||||||
# Not running, return success
|
if pgrep -x "$match_pattern" > /dev/null 2>&1; then
|
||||||
|
has_main_process=true
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Also check for related processes using fuzzy match
|
||||||
|
local has_related_processes=false
|
||||||
|
if pgrep -i "$match_pattern" > /dev/null 2>&1; then
|
||||||
|
has_related_processes=true
|
||||||
|
fi
|
||||||
|
|
||||||
|
# If nothing is running, return success
|
||||||
|
if [[ "$has_main_process" == false && "$has_related_processes" == false ]]; then
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Try graceful termination first
|
# Try graceful termination first for exact match
|
||||||
pkill -x "$match_pattern" 2> /dev/null || true
|
if [[ "$has_main_process" == true ]]; then
|
||||||
sleep 1
|
pkill -x "$match_pattern" 2> /dev/null || true
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Also try graceful termination for related processes
|
||||||
|
if [[ "$has_related_processes" == true ]]; then
|
||||||
|
pkill -i "$match_pattern" 2> /dev/null || true
|
||||||
|
fi
|
||||||
|
|
||||||
|
sleep 2
|
||||||
|
|
||||||
# Check again after graceful kill
|
# Check again after graceful kill
|
||||||
if ! pgrep -x "$match_pattern" > /dev/null 2>&1; then
|
if ! pgrep -i "$match_pattern" > /dev/null 2>&1; then
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Force kill if still running
|
# Force kill if still running
|
||||||
pkill -9 -x "$match_pattern" 2> /dev/null || true
|
pkill -9 -i "$match_pattern" 2> /dev/null || true
|
||||||
sleep 1
|
sleep 2
|
||||||
|
|
||||||
# Final check
|
# Final check with longer timeout for stubborn processes
|
||||||
pgrep -x "$match_pattern" > /dev/null 2>&1 && return 1 || return 0
|
local retries=3
|
||||||
|
while [[ $retries -gt 0 ]]; do
|
||||||
|
if ! pgrep -i "$match_pattern" > /dev/null 2>&1; then
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
sleep 1
|
||||||
|
((retries--))
|
||||||
|
done
|
||||||
|
|
||||||
|
# Still running after all attempts
|
||||||
|
pgrep -i "$match_pattern" > /dev/null 2>&1 && return 1 || return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
# Remove application icons from the Dock (best effort)
|
# Remove application icons from the Dock (best effort)
|
||||||
|
|||||||
2
mole
2
mole
@@ -22,7 +22,7 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|||||||
source "$SCRIPT_DIR/lib/core/common.sh"
|
source "$SCRIPT_DIR/lib/core/common.sh"
|
||||||
|
|
||||||
# Version info
|
# Version info
|
||||||
VERSION="1.11.21"
|
VERSION="1.11.22"
|
||||||
MOLE_TAGLINE="can dig deep to clean your Mac."
|
MOLE_TAGLINE="can dig deep to clean your Mac."
|
||||||
|
|
||||||
# Check if Touch ID is already configured
|
# Check if Touch ID is already configured
|
||||||
|
|||||||
Reference in New Issue
Block a user