Use ps keyword command instead of cmd

For Darwin operating systems, `cmd` is not a valid keyword, thus
resulting in the following error when executing Vagrant `reload` and
`destroy` commands:

    ps: cmd: keyword not found
    ps: no valid keywords; valid keywords:

This commit ensures that SSH sessions for forwarded ports are
terminated via their respective process ID for Darwin *and* Linux
operating systems.

Both Darwin and Linux operating systems support the `command` keyword,
as reflected in the following documents, respectively:

- https://apple.co/2H7jFwl
- https://bit.ly/2HakfW0
This commit is contained in:
jasonwalsh 2018-04-17 18:22:41 -04:00
parent 39f9a9d0b4
commit 45b588d7da
No known key found for this signature in database
GPG Key ID: 94C3A2B6130DC097

View File

@ -210,9 +210,9 @@ module VagrantPlugins
end end
def ssh_pid?(pid) def ssh_pid?(pid)
@logger.debug 'Checking if #{pid} is an ssh process '\ @logger.debug "Checking if #{pid} is an ssh process "\
'with `ps -o cmd= #{pid}`' "with `ps -o command= #{pid}`"
`ps -o cmd= #{pid}`.strip.chomp =~ /ssh/ `ps -o command= #{pid}`.strip.chomp =~ /ssh/
end end
def remove_ssh_pids def remove_ssh_pids