I'm doing :
print "flocking now\n";
flock (FILE, 2);
print "done flocking\n";
it prints flocking now . and freezes. If I make a copy of the file, delete the original, and then copy the copy back to the original name like so:
copy foo bar
rm foo
copy bar foo
rm bar
It'll work again but only for a while then it goes back to stopping at the flock. Using ps -A I don't see any other programs running which would flock the file.
After fiddling with it for far too long, it seems to be caused by Apache timing out. This is in a cgi script. For some reason when Apache kills it off the flock isn't undone. (near as I can figure)