commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ian Emmons <>
Subject Re: [daemon] Unable to read file created by Tomcat process
Date Sun, 16 Nov 2014 15:46:37 GMT
> On Nov 11, 2014, at 7:44 PM, Bernd Eckenfels <> wrote:
> Am Tue, 11 Nov 2014 00:09:57 -0500 schrieb Anil Ambati <>:
>> Why does the Tomcat server keep the PID file locked, preventing other processes to
even read the file? Is there a work around or solution for this problem?
> I think the reason for that is, that you can this way detect if the process is still
running: if it is locked, then it is running.

Assuming that the pid file is created in the native code of procrun, then this could be solved
by using the fine-grained sharing options of the Win32 API CreateFile (which is used to both
create and open files).  Specifically, procrun could call CreateFile so as to open the file
in a mode where other processes can read the file but not write to it by passing FILE_SHARE_READ
for the dwShareMode parameter.

This would allow other processes to read the file by opening for read-only access, and it
would also allow another process to test if the procrun process is still running by opening
with write access.

> Of course this makes it hard to read the file. To work around this I guess a native library
is needed. (Or you execute "cmd /C type"). Not sure if any component offers this
(might be a good addition to commons-daemon).

I don’t think a native library or cmd’s type command will help here -- if the OS is enforcing
exclusive access to the file, then that restriction will apply to all other processes.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message