Bug 960255 - Status Script does not return the proper PID.
Summary: Status Script does not return the proper PID.
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: tomcat6
Version: 6.6
Hardware: All
OS: Linux
unspecified
medium
Target Milestone: rc
: ---
Assignee: David Knox
QA Contact: tomcat-qe
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2013-05-06 19:33 UTC by Eric Rich
Modified: 2018-12-03 18:48 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2013-11-21 23:51:22 UTC
Target Upstream Version:


Attachments (Terms of Use)


Links
System ID Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2013:1721 normal SHIPPED_LIVE tomcat6 bug fix update 2013-11-20 21:51:34 UTC

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


Note You need to log in before you can comment on or make changes to this bug.