Subject: | fails when disk is read only |
Date: | Tue, 19 Apr 2011 10:24:21 -0700 |
To: | bug-Proc-Pidfile [...] rt.cpan.org |
From: | John Tantalo <john [...] eventful.com> |
I ran into a problem where multiple processes were running simultaneously which were all using the same pidfile.
I observed that the pidfile existed but it was empty. This contradicted my expectation that the pidfile should contain the pid of one of the running processes.
I discovered that the disk which contained /tmp was read only. I concluded that Proc::Pidfile failed because the pidfile did not contain a pid.
The expectation of Proc::Pidfile is that it should never allow two processes with the same pidfile to run simultaneously. Therefore, I expect that Proc::Pidfile should immediately exit if the disk is read only, ie., if the pid file cannot be written.
I believe the issue is in this block:
Show quoted text
> $self->_verbose( "no pidfile $pidfile\n" );
> open( PID, ">$pidfile" ) or die "Can't write to $pidfile\n";
> flock( PID, LOCK_EX );
> print PID "$$\n";
> flock( PID, LOCK_UN );
> close( PID );
> $self->_verbose( "pidfile $pidfile created\n" );
You should check the return value of print() and close() to verify that the file was written as expected.
My system details:
perl v5.8.8
Proc::Pidfile v1.004
i386 GNU/Linux