cask/artifact/abstract_uninstall: handle signal failures.

If the process is running as another user: this will always fail.
This commit is contained in:
Mike McQuaid 2023-12-20 19:43:46 +00:00
parent dde0411e02
commit 228b1d62ed
No known key found for this signature in database
GPG Key ID: 3338A31AFDB1D829

View File

@ -279,8 +279,13 @@ module Cask
# misapplied "kill" by root could bring down the system. The fact that we
# learned the pid from AppleScript is already some degree of protection,
# though indirect.
# TODO: check the user that owns the PID and don't try to kill those from other users.
odebug "Unix ids are #{pids.inspect} for processes with bundle identifier #{bundle_id}"
begin
Process.kill(signal, *pids)
rescue Errno::EPERM => e
opoo "Failed to kill #{bundle_id} PIDs #{pids.join(", ")} with signal #{signal}: #{e}"
end
sleep 3
end
end