MymsMan
Ad detector
Bit of a hack, but you could do a mkdir/rmdir?
i.e. make a dir with a name encoded from the filename, using that dir's existence as the lock. A dir is easier than a file, as mkdir can then both be the taking, and the testing, of the lock.
I could, but if the process creating the directory dies before it has the chance to do the rmdir the lock is left permanently set - I need something that is automatically unset on failure.
I think I will create a lock file and use INUSE as the actual lock. In my usage scenario I don't anticipate race conditions to acquire the lock so the lack of atomicity in the testing for and setting INUSE shouldn't (famous last words) be a problem.