I have a small application consisting of two process.
Process A downloads a file. Process B uses the downloaded file.
When Process A downloads a file, it acquires file lock on it. Process B keep checking whether the file being downloaded is locked or not.
Once the downloading is completed, Process A releases file lock and the downloaded file is ready to use by Process B.
In Process B, I have dedicated thread which checks if the lock is released.
I want to avoid the loop of continuous file-lock check. Is there a way similar to select
or poll
system call using which Process B gets notifies about the file lock getting released ?
I have explored man pages of fcntl, flock but I did not find a way to do it.