My program is to scan a directory for new files, and then forward them along. However, I cannot forward a file until it is complete, and as far as I'm aware, the only way to tell if the file is complete is if no other process is accessing it.
I tried checking for write locks using fcntl, but either I'm using it wrong or the process doesn't put a write lock on the file.
So basically, I'm looking for something similar to fuser <file> or lsof <file>. What command/library am I looking for here? Don't say "exec", because there's no sense getting a full wheel when all you need is a spoke.
Thanks in advance,
(If you want me to post the code I tried to check for locks, just say so, but I figured there's nothing further to be said there)