diff --git a/rpid b/rpid index b1f2b71..fb733d0 100755 --- a/rpid +++ b/rpid @@ -3,7 +3,8 @@ USAGE=' USAGE: rpid [=login] - pid The PID of the process for which you want to find the root PID. + pid The PID of the process for which you want to find the root + PID. Defaults to $$. root_name The name (not command line) of the root process, for which @@ -20,16 +21,16 @@ EXAMPLES: Get the PID of the login process that is the ancestor of the current process. - rpid $$ + rpid ' # Validate the arguments -if [[ "$#" -lt 1 || "$#" -gt 2 ]]; then +if [[ "$#" -gt 2 ]]; then printf '%s' "${USAGE}" 1>&2 - exit 128 + exit 64 fi -pid="$1" +pid="${1:-$$}" # Check if the user needs help if [[ "${pid}" =~ ^(-h|-(-)?help)$ ]]; then