[Omaha.pm] Differences to expect when using flock() on different OS and Filesystems.

Dan Linder dan at linder.org
Tue Apr 21 06:51:38 PDT 2009


As an off-shoot of my fork()/wait() discussion, I began researching the
flock() function so I can ensure that the processes don't step on each other
if they try to update the same file.  In our code, 90% of the file updates
in the section I'm working on are not going to conflict.  In the remaining
code, there are a couple files that will expose a race condition, so some
sort of file locking will be needed.

A co-worker cast a vague warning that the flock() implementation varies
widely based on the OS and filesystem it's working on.  I Googled quite a
bit last night and I can't find any specific examples of other warnings (and
work-arounds).

This code is gonig to run on Unix based systems (Solaris, RedHat, SUSE,
HPUX, AIX, etc) and the only OS-based Perl warnings I can find are related
to how Perl reacts on Windows when compared to Unix.

Has anyone run into examples of flock() failing subiltly (or not-so subtily)
between various flavors of Unix and/or filesystems?

Thanks,

Dan

"Quis custodiet ipsos custodes?" (Who can watch the watchmen?) -- from the
Satires of Juvenal
"I do not fear computers, I fear the lack of them." -- Isaac Asimov (Author)
** *** ***** ******* *********** *************
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/omaha-pm/attachments/20090421/574bd87b/attachment.html>


More information about the Omaha-pm mailing list