Bug 50084 - catalina.sh fix in #49728 breaks PID handling again
Summary: catalina.sh fix in #49728 breaks PID handling again
Status: RESOLVED FIXED
Alias: None
Product: Tomcat 6
Classification: Unclassified
Component: Catalina (show other bugs)
Version: unspecified
Hardware: PC All
: P2 normal (vote)
Target Milestone: default
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
: 50130 (view as bug list)
Depends on:
Blocks:
 
Reported: 2010-10-13 08:06 UTC by Robert Oschwald
Modified: 2010-10-26 12:15 UTC (History)
2 users (show)



Attachments
Patch to fix existing, empty pid file handling (805 bytes, application/octet-stream)
2010-10-13 08:56 UTC, Robert Oschwald
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Robert Oschwald 2010-10-13 08:06:57 UTC
The pid handling fix in #49728 breaks PID handling again.

The fix now removes empty PID files before start.
This doesn't work on RHEL5/CentOS5 (and maybe others), where tomcat is started as non-root user.

The pid files on these OS's are in /var/run, which is only writeable by root.
Therefore, the init.d script creates the pid file and sets the permissions accordinghly.
This is not working anymore, as catalina.sh tries to remove this empty file and skips filling the file as it cant remove it.
Comment 1 Konstantin Kolinko 2010-10-13 08:42:26 UTC
What is your suggestion how to deal with it?

I might think about truncating the stale PID file instead of deleting it.


To truncate a file one might redirect empty output to it, as shown in [1], using the "colon" (no-op) command:

:>"$CATALINA_PID"

[1] http://linuxdemon.blogspot.com/2007/06/how-to-truncate-file-in-unixlinux.html

The following also works:
true>"$CATALINA_PID"
Comment 2 Robert Oschwald 2010-10-13 08:48:16 UTC
In my opinion, thats not necessary.

I will add a patch to this ticket with my workaround to the problem.
Basically, when an empty pid file exists, its' just filled by catalina.sh
Comment 3 Robert Oschwald 2010-10-13 08:56:37 UTC
Created attachment 26167 [details]
Patch to fix existing, empty pid file handling

Note: echo $! > "$CATALINA_PID" creates the file if not existent and fills existing files (overwrites existing content)
Comment 4 Mark Thomas 2010-10-19 10:55:58 UTC
Thanks for the report and the suggested patch.

I applied a different patch that retained the current behavior where the containing dir is writable but better handles (without error messages) the case where it is not.

Fixed for 7.0.x and will be included in 7.0.5 onwards.

Proposed for 6.0.x.
Comment 5 Mark Thomas 2010-10-21 07:58:33 UTC
*** Bug 50130 has been marked as a duplicate of this bug. ***
Comment 6 Mark Thomas 2010-10-26 12:15:36 UTC
Fixed in trunk and will be in 6.0.30 onwards.