- You can't lock a file without having a filehandle that references that file;
- File locks do not survive fork().
One possible solution to your problem would be to have a DBF file with a list of all files that are currently locked. The files themselves would not be locked via flock() but access to the DBF file would be gated through flock().
Advantage: locks will be maintained even if your server/client crashes and is then restarted;
Disadvantage: having all processes use the same file may create a bottleneck. To minimize the probability of this happening, make sure the DBF file is locked only when necessary.
Hope this helps.
--perlplexer