1. flock() bug in Perl, Linux, or FreeBSD?
I have one acount on a Linux ISP, and another on FreeBSD. On
both systems, the straightforward C equivalent of the Perl
script below works exactly as expected: run 3 simultaneous
copies, and you get a nicely incremented counter, with mixed
pids, indicating that flock() is doing its job. The Perl
script itself, doing exactly the same thing, generates a list
of duplicated numbers, indicating that simultaneous reads are
being allowed. The perl code is calling flock(). It doesn't
matter if you replace the flock() operator with the syscall()
equivalent, it still fails, so I suspect the problem is with
the OS, but I'm surprised the behavior is identical between
Linux and BSD. Whose bug is it?
#!/usr/local/bin/perl5.001
#
# Expects 'counter' to be a file with one line, which
# is just an ASCII integer.
open(COUNTER, "+<counter") || die "open failed";
for (1..10) {
flock(COUNTER, 2) || die "lock failed";
seek(COUNTER, 0, 0); # read current count
chop($count = <COUNTER>);
print "$$: $count\n"; # display pid, count
++$count;
seek(COUNTER, 0, 0); # write incremented count
print COUNTER "$count\n";
flock(COUNTER, 8) || die "unlock failed";
close COUNTER;
exit 0;
2. What did I do wrong?
3. Bug in flock() ???
4. Fedora Core2 + Wireless Question
5. Sherlock linux plug-ins / sherlock for linux?
6. named pipe read by many
7. List of plug-ins for linux/netscape please!
8. Questions about ports collection...
9. Errors compiling Wingz 1.4 Add-ins (Linux 1.3.99, GCC 2.6)
10. Linux and Dial-ins (?)
11. netscape-i686-pc-linux-gnu-installer.tar.gz for Netscape 6.1 ppc?
12. Netscape plug-ins under Linux
13. how to use plug-ins in navigator-linux?