mirror of
https://github.com/arkenfox/user.js.git
synced 2025-04-30 14:03:40 +02:00
prefsCleaner: fix profile-in-use check on Linux
This commit is contained in:
parent
ea139e3ef8
commit
0c2cc1005d
1 changed files with 25 additions and 2 deletions
|
@ -31,10 +31,33 @@ Optional Arguments:
|
||||||
-s Start immediately"
|
-s Start immediately"
|
||||||
}
|
}
|
||||||
|
|
||||||
fFF_check() {
|
fFF_check_linux() {
|
||||||
|
local target="$(readlink lock)" || return 1
|
||||||
|
local pid="${target#*+}"
|
||||||
|
# Account for PID reuse on Linux.
|
||||||
|
local procdir="/proc/$pid/fd"
|
||||||
|
[[ -d "$procdir" ]] || return 1
|
||||||
|
parentlock="$(realpath .parentlock)"
|
||||||
|
readlink "$procdir"/* | grep -Fqx "$parentlock"
|
||||||
|
}
|
||||||
|
|
||||||
|
fFF_check_macos() {
|
||||||
# there are many ways to see if firefox is running or not, some more reliable than others
|
# there are many ways to see if firefox is running or not, some more reliable than others
|
||||||
# this isn't elegant and might not be future-proof but should at least be compatible with any environment
|
# this isn't elegant and might not be future-proof but should at least be compatible with any environment
|
||||||
while [ -e lock ]; do
|
[[ -e lock ]]
|
||||||
|
}
|
||||||
|
|
||||||
|
fFF_check() {
|
||||||
|
local variant=''
|
||||||
|
case "$(uname -s)" in
|
||||||
|
Linux) variant='linux' ;;
|
||||||
|
Darwin) variant='macos' ;;
|
||||||
|
*)
|
||||||
|
echo -e "\nPlease make sure the Firefox profile is not in use before continuing.\n" >&2
|
||||||
|
read -r -p "Press any key to continue."
|
||||||
|
return
|
||||||
|
esac
|
||||||
|
while "fFF_check_$variant"; do
|
||||||
echo -e "\nThis Firefox profile seems to be in use. Close Firefox and try again.\n" >&2
|
echo -e "\nThis Firefox profile seems to be in use. Close Firefox and try again.\n" >&2
|
||||||
read -r -p "Press any key to continue."
|
read -r -p "Press any key to continue."
|
||||||
done
|
done
|
||||||
|
|
Loading…
Add table
Reference in a new issue