sx: unconditionally run xauth remove in cleanup
Even if xauth(1) fails before we get a $pid for cleanup, make sure to run xauth remove during cleanup.
This commit is contained in:
parent
161b8be6f5
commit
6b089b8d50
9
sx
9
sx
|
@ -23,7 +23,7 @@ cleanup() {
|
||||||
# regardless of failure.
|
# regardless of failure.
|
||||||
set +o errexit
|
set +o errexit
|
||||||
|
|
||||||
if [ "$(ps -o comm= "$1")" = Xorg ]; then
|
if [ "$1" ] && [ "$(ps -o comm= "$1")" = Xorg ]; then
|
||||||
kill "$1"
|
kill "$1"
|
||||||
|
|
||||||
# Send SIGKILL after 10 seconds if the xserver is taking too long to
|
# Send SIGKILL after 10 seconds if the xserver is taking too long to
|
||||||
|
@ -34,18 +34,17 @@ cleanup() {
|
||||||
124) kill -s KILL "$1"
|
124) kill -s KILL "$1"
|
||||||
esac
|
esac
|
||||||
|
|
||||||
xauth remove :"$tty"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! stty "$stty"; then
|
if ! stty "$stty"; then
|
||||||
stty sane
|
stty sane
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
xauth remove :"$tty"
|
||||||
exit
|
exit
|
||||||
}
|
}
|
||||||
|
|
||||||
stty=$(stty -g)
|
stty=$(stty -g)
|
||||||
|
|
||||||
tty=$(ps -o tty= $$)
|
tty=$(ps -o tty= $$)
|
||||||
|
|
||||||
case $tty in
|
case $tty in
|
||||||
|
@ -58,11 +57,11 @@ XAUTHORITY=${XAUTHORITY:-$cfgdir/xauthfile}
|
||||||
|
|
||||||
mkdir -p "$cfgdir" "$datadir"
|
mkdir -p "$cfgdir" "$datadir"
|
||||||
|
|
||||||
trap 'cleanup "$pid"' EXIT
|
|
||||||
|
|
||||||
touch "$XAUTHORITY"
|
touch "$XAUTHORITY"
|
||||||
export XAUTHORITY
|
export XAUTHORITY
|
||||||
|
|
||||||
|
trap 'cleanup "$pid"' EXIT
|
||||||
|
|
||||||
xauth add :"$tty" MIT-MAGIC-COOKIE-1 "$(mcookie)"
|
xauth add :"$tty" MIT-MAGIC-COOKIE-1 "$(mcookie)"
|
||||||
|
|
||||||
# Xorg will check if SIGUSR1 was set to SIG_IGN in its environment and issue
|
# Xorg will check if SIGUSR1 was set to SIG_IGN in its environment and issue
|
||||||
|
|
Loading…
Reference in New Issue