According to the modperl documentation: http://perl.apache.org/docs/1.0/guide/debug.html#Safe_Resource_Locking_a nd_Cleanup_Code
The simplest solution to this problem is to always use lexically scoped variables (created with my ()). Whether script gets aborted before close() is called or you forgot the use close() the lexically scoped variable will always go out of scope and therefore if the file was locked it will be unlocked. Here is a good version of the code: flock4.pl --------- use Fcntl qw(:flock); use Symbol (); my $fh = Symbol::gensym(); open $fh, "+>>filename" or die "$!"; flock $fh, LOCK_EX; # do something close $fh; Notice they do not mention using LOCK_UN. Also Dominus says that " Using LOCK_UN is almost always a mistake" http://perl.plover.com/yak/flock/samples/slide005.html Any other ideas? -----Original Message----- From: Robert Landrum [mailto:[EMAIL PROTECTED] Sent: Friday, April 13, 2007 1:07 PM To: Justin Luster Cc: [EMAIL PROTECTED] Subject: Re: Lock Files - File is permanently locked Justin Luster wrote: > Does anyone know what might be happening? We are only using > Apache::Registry in this instance. I can't see how a lexically scoped > file handle that is being locked is not being unlocked once the process > ends. The process isn't ending if you're using Apache::Registry. I think you'll need to use Fcntl qw(:flock); flock $FileHandle, LOCK_UN; unless you set the Max child process config option to 1 (in which case, apache::registry would be useless). Also, if you're using child locking like this, you can write the requesting process's PID to the .lock (or whatever) file. Then a cron job could come along and reap your .lock's if the PID is no longer running. Then your file would only ever be locked for at most a minute. Seems like overkill though. Rob