# shellcheck shell=bash #============================================================================== # Copyright and license info is available in the LICENSE file included with # the Server Deployment Package (SDP), and also available online: # https://workshop.perforce.com/view/p4-sdp/dev/LICENSE #------------------------------------------------------------------------------ # Common functions for using 'ps' to check on process ids. #------------------------------------------------------------------------------ # Function: get_pids ($exe) # Usage: Call with an exe name, e.g. /p4/1/bin/p4broker_1 # # Example: # p4broker_pids=$(get_pids $P4BROKERBIN) # # This implementation works on a variety of UNIX/Linux systems and Mac OSX. function get_pids () { local exe=${1:-} local pids= pids=$($PS -ef|$GREP "${exe}"| $GREP -v " $GREP " | $GREP -v "${exe}_init " | $AWK '{print $2}') echo $pids }