Thread: Perl code
View Single Post
Old 08-24-2002, 12:14 PM  
willow
Confirmed User
 
Join Date: Dec 2001
Location: NY, NY, USA
Posts: 131
perldoc -f flock

Here's a mailbox appender for BSD systems.

use Fcntl ':flock'; # import LOCK_* constants

sub lock {
flock(MBOX,LOCK_EX);
# and, in case someone appended
# while we were waiting...
seek(MBOX, 0, 2);
}

Just to clarify what the seek is really for and why you usually get away without needing it. The whole exercise however was to avoid race conditions.
willow is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote