# therefore, the safest way to ensure unique sockets while not having to
# write specific logic for both scenarios is to simply change GNUPGHOME.
# the easiest way to do this is to create a new dir and link the contents
-# of GNUPGHOME to the new home. we can then replace the agent sockets
-# there with the forwarded one.
+# of GNUPGHOME to the new home. we can then replace all of the agent
+# sockets wherever they now are with the forwarded one. in either case we
+# will be overwriting the session-specific sockets.
#
# NOTE: since Unix sockets are not supported under Windows, this will not work
# under msys, cygwin, mingw, etc., but may work under wsl2.
if [[ -f $e ]] {
IFS=$'\0' read -r sock pid <$e
}
- if [[ -S $sock && $pid > 0 ]] && kill -0 $pid; then
+ if [[ -S $sock && $pid > 0 ]] && kill -0 $pid >/dev/null 2>&1; then
[[ -o interactive ]] && print -P "Reusing agent PID $pid%f"
export SSH_AUTH_SOCK=$sock
export SSH_AGENT_PID=$pid