1
0
mirror of https://github.com/tw93/Mole.git synced 2026-02-08 19:04:20 +00:00

More secure deletion and cannot delete path

This commit is contained in:
Tw93
2025-11-14 11:38:25 +08:00
parent ddef8c4bc0
commit 4f8f31444d
5 changed files with 139 additions and 10 deletions

View File

@@ -452,8 +452,22 @@ uninstall_applications() {
read -p " Force quit $app_name? (y/N): " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
pkill -f "$app_path" 2> /dev/null || true
sleep 2
# Retry kill operation with verification to avoid TOCTOU
local retry=0
while [[ $retry -lt 3 ]]; do
pkill -f "$app_path" 2> /dev/null || true
sleep 1
# Verify app was killed
if ! pgrep -f "$app_path" > /dev/null 2>&1; then
break
fi
((retry++))
done
# Final check
if pgrep -f "$app_path" > /dev/null 2>&1; then
log_warning "Failed to quit $app_name after $retry attempts"
fi
else
echo -e " ${BLUE}${ICON_EMPTY}${NC} Skipped $app_name"
continue