From 7c59c4d0adebe2fc48603d635630c84a81d4116e Mon Sep 17 00:00:00 2001 From: Jeff Kinslow Date: Sun, 22 Sep 2013 14:44:38 -0400 Subject: [PATCH] fix ssh module starting redundant agents in cygwin --- modules/ssh/init.zsh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/modules/ssh/init.zsh b/modules/ssh/init.zsh index 320f7635..0977ad38 100644 --- a/modules/ssh/init.zsh +++ b/modules/ssh/init.zsh @@ -21,10 +21,14 @@ _ssh_agent_sock="$TMPDIR/ssh-agent.sock" # Start ssh-agent if not started. if [[ ! -S "$SSH_AUTH_SOCK" ]]; then - eval "$(ssh-agent | sed '/^echo /d' | tee "$_ssh_agent_env")" -else # Export environment variables. source "$_ssh_agent_env" 2> /dev/null + # Check if process is still running. + ps -ef | grep ${SSH_AGENT_PID} | grep ssh-agent$ &> /dev/null || { + eval "$(ssh-agent | sed '/^echo /d' | tee "$_ssh_agent_env")" + # Source new environment variables. + source "$_ssh_agent_env" 2> /dev/null + } fi # Create a persistent SSH authentication socket.