ps option -U and -o unknown #172

Closed
Brottweiler opened this Issue Jun 13, 2014 · 2 comments

Projects

None yet

3 participants

@Brottweiler

I use Prezto instead of Oh-My-Zsh, and the SSH module checks if SSH-agent is running when I open babun. This works on linux, because it uses ps -U to check if it's running for my user, but the -U option doesn't exist in ps in babun.

This is how the SSH module looks like at the part where it checks if SSH-agent is started.

# Start ssh-agent if not started.
if [[ ! -S "$SSH_AUTH_SOCK" ]]; then
  # Export environment variables.
  source "$_ssh_agent_env" 2> /dev/null

  # Start ssh-agent if not started.
  if ! ps -U "$USER" -o pid,ucomm | grep -q "${SSH_AGENT_PID} ssh-agent"; then
    eval "$(ssh-agent | sed '/^echo /d' | tee "$_ssh_agent_env")"
  fi
fi

ps --help shows that -U and -o does not exist as options. Is there a package where these options are included?

@jlupi
Contributor
jlupi commented Jun 27, 2014

There is no -o option in cygwin's ps but there is -u:

-u, --user list processes owned by UID

You could try to replace the if with one of those (depends whether the agent is a windows or cygwin process):

if ! ps -u "$USER"  | egrep -q -e "${SSH_AGENT_PID}.*ssh-agent"; then

or

if ! ps -u "$USER" -W | egrep -q -e "${SSH_AGENT_PID}.*ssh-agent"; then
@tombujok
Contributor
tombujok commented Feb 4, 2015

Thanks for feedback @jlupi
Moved to FAQ and closed.

@tombujok tombujok closed this Feb 4, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment