Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
For bugs related to Red Hat Enterprise Linux 5 product line. The current stable release is 5.10. For Red Hat Enterprise Linux 6 and above, please visit Red Hat JIRA https://issues.redhat.com/secure/CreateIssue!default.jspa?pid=12332745 to report new issues.

Bug 463205

Summary: mistake in /etc/init.d/functions file's status function
Product: Red Hat Enterprise Linux 5 Reporter: Balazs Zachar <balazs.zachar>
Component: initscriptsAssignee: initscripts Maintenance Team <initscripts-maint-list>
Status: CLOSED DUPLICATE QA Contact: BaseOS QE <qe-baseos-auto>
Severity: low Docs Contact:
Priority: medium    
Version: 5.2CC: notting
Target Milestone: rc   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2008-09-24 14:15:35 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Balazs Zachar 2008-09-22 15:36:50 UTC
Description of problem:
I have to run two service with the same name (and same binary but different config) but different pidfile and I have to monitor these processes (with the status argument with its init scripts).
Situation: One service from the two is running (A) and the second is not running (B).
I would like to "monitor" the B service with its init script using the status argument and I get that: this service is running...(BUT NOT)
The init scripts's status argument call the functions file's status function with the -p $PIDFILE argument to determine the process's status. But because the status function in the functions file firstly do pid="$(__pids_pidof "$1")" where $1 is the program's name it didn't use my PIDFILE argument and here it gets the A process's pid and returns with the A process status and not with the B's status. I think it should use the pidfile first to determine the process's pid if somebody give that argument...

Version-Release number of selected component (if applicable):
# rpm -qf /etc/init.d/functions 
initscripts-8.45.19.EL-1

How reproducible:
see Description

Comment 1 Bill Nottingham 2008-09-23 19:17:17 UTC
        # Find pid.
        __pids_var_run "$1" "$pid_file"
        if [ -z "$pid_file" -a -z "$pid" ]; then
                pid="$(__pids_pidof "$1")"
        fi

I'm confused - how is this not using the pidfile?

Comment 2 Balazs Zachar 2008-09-24 07:05:40 UTC
(In reply to comment #1)
>         # Find pid.
>         __pids_var_run "$1" "$pid_file"
>         if [ -z "$pid_file" -a -z "$pid" ]; then
>                 pid="$(__pids_pidof "$1")"
>         fi
> 
> I'm confused - how is this not using the pidfile?

I had problem with the status function not with the killproc... (killproc works fine)

status function's begin:
    status() {
        local base pid pid_file=

        # Test syntax.
        if [ "$#" = 0 ] ; then
                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")"
        if [ -n "$pid" ]; then
                echo $"${base} (pid $pid) is running..."
                return 0
        fi

Here, you first try the pidof before you use the pidfile to determine the process's pid. So, pidof find the A process's pid and give me the A process's status instead of B.

Comment 3 Bill Nottingham 2008-09-24 14:15:35 UTC

*** This bug has been marked as a duplicate of bug 440658 ***