sx: no longer attempt to send SIGKILL
Sending SIGKILL is not an appropriate response in most cases especially after an arbitrary timeout. If signals are being ignored it's likely due to D state. If the process is busy spinning in an infinite loop then bug reports need to be made. Papering over significant issues is worse for everyone in the end. This commit also trusts the PID we get is an xorg server process. I have no real reason to check outside of paranoia which borders on theater. Instead I check the PID is still alive and send TERM. Then we wait until it is done. Anything else is surely abnormal and needs manual intervention.
This commit is contained in:
parent
1b3506d21f
commit
9f2c0c5fb4
24
sx
24
sx
|
@ -8,26 +8,9 @@
|
||||||
set -o errexit
|
set -o errexit
|
||||||
|
|
||||||
cleanup() {
|
cleanup() {
|
||||||
# Return to conventional flow control here as we need to continue
|
if kill -0 "$1" 2> /dev/null; then
|
||||||
# regardless of failure.
|
kill -s TERM "$1"
|
||||||
set +o errexit
|
wait "$1"
|
||||||
|
|
||||||
if [ "$1" ] && [ "$(ps -o comm= "$1")" = Xorg ]; then
|
|
||||||
kill "$1"
|
|
||||||
|
|
||||||
# Send SIGKILL after 10 seconds if the xserver is taking too long to
|
|
||||||
# terminate.
|
|
||||||
interval=10
|
|
||||||
while kill -0 "$1" 2> /dev/null; do
|
|
||||||
if [ "$interval" -le 0 ]; then
|
|
||||||
if [ "$(ps -o comm= "$1")" = Xorg ]; then
|
|
||||||
kill -s KILL "$1"
|
|
||||||
fi
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
interval=$((interval - 1))
|
|
||||||
sleep 1
|
|
||||||
done
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! stty "$stty"; then
|
if ! stty "$stty"; then
|
||||||
|
@ -35,6 +18,7 @@ cleanup() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
xauth remove :"$tty"
|
xauth remove :"$tty"
|
||||||
|
|
||||||
exit
|
exit
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue