Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 960255

Summary: Status Script does not return the proper PID.
Product: Red Hat Enterprise Linux 6 Reporter: Eric Rich <erich>
Component: tomcat6Assignee: David Knox <dknox>
Status: CLOSED ERRATA QA Contact: tomcat-qe
Severity: medium Docs Contact:
Priority: unspecified    
Version: 6.6CC: jclere, lkonno, mhasko
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: 2013-11-21 23:51:22 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Eric Rich 2013-05-06 19:33:56 UTC
Description of problem:

Tomcat should return 

      log_success_msg "${NAME} (pid ${kpid}) is running..."

and not: 

      log_success_msg "${NAME} (pid $pid) is running..."

When Running a status under normal conditions. 

Because of the checkpidfile function the status function never runs the first if statement. (Functions Below) 

function checkpidfile()
{
    if [ -f "${CATALINA_PID}" ]; then
       read kpid < ${CATALINA_PID}
       if [ -d "/proc/${kpid}" ]; then
# The pid file exists and the process is running
           RETVAL="0"
       else
# The pid file exists but the process is not running
          RETVAL="1"
          return
       fi
    fi
# pid file does not exist and program is not running
    RETVAL="3"
}

function status()
{
   checkpidfile
   if [ "$RETVAL" -eq "0" ]; then
      log_success_msg "${NAME} (pid ${kpid}) is running..."
   elif [ "$RETVAL" -eq "1" ]; then
      log_failure_msg "PID file exists, but process is not running"
   else
      checklockfile
      if [ "$RETVAL" -eq "2" ]; then
         log_failure_msg "${NAME} lockfile exists but process is not running"
      else
         pid="$(/usr/bin/pgrep -u ${TOMCAT_USER} -f ${NAME})"
         if [ -z "$pid" ]; then
             log_success_msg "${NAME} is stopped"
             RETVAL="3"
         else
             log_success_msg "${NAME} (pid $pid) is running..."
             RETVAL="0"
         fi
      fi
  fi
}

The following should be the fix to this issue: 

--- tomcat6.orig        2013-05-01 14:57:59.231736488 -0400
+++ /etc/init.d/tomcat6 2013-05-01 15:04:06.463736580 -0400
@@ -231,14 +231,17 @@ function checkpidfile()
       if [ -d "/proc/${kpid}" ]; then
 # The pid file exists and the process is running
           RETVAL="0"
+         return
       else
 # The pid file exists but the process is not running
          RETVAL="1"
          return
       fi
-   fi
+   else
 # pid file does not exist and program is not running
-   RETVAL="3"
+      RETVAL="3"
+      return
+   fi
 }

Comment 5 errata-xmlrpc 2013-11-21 23:51:22 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

http://rhn.redhat.com/errata/RHBA-2013-1721.html