summaryrefslogtreecommitdiff
path: root/bin/emacsclient
diff options
context:
space:
mode:
Diffstat (limited to 'bin/emacsclient')
-rwxr-xr-xbin/emacsclient10
1 files changed, 3 insertions, 7 deletions
diff --git a/bin/emacsclient b/bin/emacsclient
index 5279effd..ff6b071e 100755
--- a/bin/emacsclient
+++ b/bin/emacsclient
@@ -83,7 +83,7 @@ eval set -- "$getopt"
get_listener () {
local socket=$1 listener= listener_age= rematch_listener= rematch_age=
# Find the youngest process listening on a socket of this name.
- while read -r line; do
+ [ -e "$socket" ] && while read -r line; do
[[ $line =~ ,pid=([[:digit:]]+), ]] || continue
rematch_listener=${BASH_REMATCH[1]}
rematch_age="$(ps h -o etimes $rematch_listener)"
@@ -94,12 +94,8 @@ get_listener () {
listener_age=$rematch_age
fi
done < <(ss -plx src "$(realpath "$socket")")
- if [ -z "$listener" -a -e "$socket" ]; then
- # Nothing is listening: remove dangling socket.
- rm "$socket"
- else
- echo "$listener"
- fi
+ # If nothing is listening, remove any dangling socket.
+ [ -n "$listener" ] && echo "$listener" || rm -f "$socket"
}
gud_status () {