On 09/28/2010 06:59 PM, ma...@apache.org wrote:
Author: markt
Date: Tue Sep 28 16:59:54 2010
New Revision: 1002263

URL: http://svn.apache.org/viewvc?rev=1002263&view=rev
Log:
Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=49728
Improve PID file handling, particularly when another process creates it and 
Tomcat is unable to write to the file.


Why not creating a function that would manage a pid file?
Seems to me there are lots of redundant code here.


+          if [ -w "$CATALINA_PID" ]; then
+            echo "Removing stale PID file."
+            rm "$CATALINA_PID"
+          else
+            echo "Unable to remove stale PID file. Start aborted."
+            exit 1
+          fi

Also I would rater check the return value from rm "$CATALINA_PID"
then checking if the file is writable.
File can be writable, but locked, so the rm would fail.
Also ro files and trigger rm interactive mode
'rm: remove write-protected regular file 'file' ?'
Using rm -f "$CATALINA_PID" and checking for $? != 0 would
handle all the cases..

eg, instead the upper code use:

rm -f "$CATALINA_PID" 2>/dev/null
if [ $? != 0 ]; then
  echo "Unable to remove stale PID file. Start aborted."
  exit 1
fi


Next the code
> echo "Tomact stopped but PID file could not be removed ($CATALINA_PID)."

Will fail on shells that handle ( ...) like ` ... `




Regards
--
^TM

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to