As I understand it, in C, if I open (create) a file and want to lock it, I should pass in the O_EXLOCK flag at the same time, otherwise, I've got a race condition, another process could potentially lock the file after I've created it, but before I've locked it.

Does Perl have this problem if I use:

open (FILE, "data.txt");
flock (FILE, 2);

Basically, I want to have a cgi that controls an external device and I want it to read a config file to find the last user (IP) and state of the device before trying to do anything. And being a cgi, I don't want race issues.

James
  • flock James Reynolds

Reply via email to