In my apps, I need to check whether a given file has been opened for writing for another process, and even this file has been opened my app just skip this file and no "die"-like things will happen here.
more detailed description of my problem:
there are two process involved. process A , which is the producer process, process B which is the consumer processw.
process A will create some requests for B to handle and the way he creates request is just create a txt-based file under a certain directory. when A create the request, he dose not know whether B is alive or not, what he needs to do is just drop the request, kind of like write a email to B. after create the request file, A will never visite it again.
prpcess B , is sometime up and sometime down. when it is running, B will "spool" the directory which A drop reqeusts. for each requst file, B just read it hand it and remove it.
but I think there is some race condition there. For example, A just open a file and is on the way of filling up the file with a request and then B want to read the same file and hand it.
my question is how should I hand the race condition gracefully in perl ?