From f566bcc31b7b3be98a6b148e9dfa9f6d86741beb Mon Sep 17 00:00:00 2001 From: Miloslav Trmac Date: Fri, 27 Jan 2006 15:55:06 +0000 Subject: Add -p to status() (#134363) --- rc.d/init.d/functions | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'rc.d/init.d/functions') diff --git a/rc.d/init.d/functions b/rc.d/init.d/functions index 4b89cdad..7ba1090a 100755 --- a/rc.d/init.d/functions +++ b/rc.d/init.d/functions @@ -298,14 +298,18 @@ pidofproc() { } status() { - local base=${1##*/} - local pid + local base pid pid_file= # Test syntax. if [ "$#" = 0 ] ; then - echo $"Usage: status {program}" + echo $"Usage: status [-p pidfile] {program}" return 1 fi + if [ "$1" = "-p" ]; then + pid_file=$2 + shift 2 + fi + base=${1##*/} # First try "pidof" pid="$(__pids_pidof "$1")" @@ -315,8 +319,9 @@ status() { fi # Next try "/var/run/*.pid" files - if [ -f /var/run/${base}.pid ] ; then - read pid < /var/run/${base}.pid + [ -z "$pid_file" ] && pid_file=/var/run/${base}.pid + if [ -f "$pid_file" ] ; then + read pid < "$pid_file" if [ -n "$pid" ]; then echo $"${base} dead but pid file exists" return 1 -- cgit v1.2.1