From 29953f64b7f6ed1abaeb61d981f7ffb19c3b8e1e Mon Sep 17 00:00:00 2001 From: Earnestly Date: Fri, 8 Dec 2017 11:35:31 +0000 Subject: [PATCH] sx: silence kill -0 diagnostics This condition will always be triggered even if the Xorg server terminates promptly. This will simply result in confusing diagnostics being printed in the common case. As kill has no quiet option, I will have to unfortunately silence them instead. --- sx | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/sx b/sx index 49220c8..da8c4d5 100755 --- a/sx +++ b/sx @@ -18,9 +18,8 @@ cleanup() { # Send SIGKILL after 10 seconds if the xserver is taking too long to # terminate. interval=10 - while kill -0 "$1"; do + while kill -0 "$1" 2> /dev/null; do if [ "$interval" -le 0 ]; then - # Make sure the PID is still (probably) an Xorg process. if [ "$(ps -o comm= "$1")" = Xorg ]; then kill -s KILL "$1" fi @@ -56,12 +55,11 @@ trap 'cleanup "$pid"' EXIT xauth add :"$tty" MIT-MAGIC-COOKIE-1 "$(od -An -N16 -tx /dev/urandom | tr -d ' ')" -# Xorg will check if SIGUSR1 was set to SIG_IGN in its environment and issue -# its own SIGUSR1 back to the parent process when it is ready to accept -# connections. See Xserver(1). - -# We take advantage of this feature to launch our client directly from the -# SIGUSR1 handler and avoid the need to poll for readiness. +# Xorg will check if its SIGUSR1 disposition is SIG_IGN and use this state to +# reply back to the parent process with SIGUSR1 as an indication it is ready +# to accept connections. +# Taking advantage of this feature allows us to launch our client directly +# from the SIGUSR1 handler and avoid the need to poll for server readiness. trap 'DISPLAY=:$tty "${@:-$cfgdir/sxrc}"' USR1 ( trap '' USR1