3.2.39 flockflock
This function calls
flock
(2) on $LOCK_SH = 1; $LOCK_EX = 2; $LOCK_NB = 4; $LOCK_UN = 8; sub lock { flock MBOX, $LOCK_EX; # and, in case someone appended # while we were waiting... seek MBOX, 0, 2; } sub unlock { flock MBOX, $LOCK_UN; } open MBOX, ">>/usr/spool/mail/$ENV{'USER'}" or die "Can't open mailbox: $!"; lock(); print MBOX $msg, "\n\n"; unlock(); Note that flock is unlikely to work on a file being accessed through a network file system. |
|