# Process A
open DATAFILE, "+< $datafile" or die ...; flock DATAFILE, LOCK_EX;
seek DATAFILE, 0, 2; print DATAFILE, $newdata;
flock DATAFILE, LOCK_UN;
# do something else for awhile
The $newdata might still be in the standard I/O buffer when the file is unlocked!
Or some of it might still be in the buffer
Result: Other processes see a garbled file
When process A exits, the buffer is flushed
Even though some other process holds the lock by then!
|Next||Copyright © 2003 M. J. Dominus|