The fact that locking behaviour differs in general by platform is not relevant because (see manual link labelled 'it' in earlier reply) flock deliberately uses its own advisory locking irrespective of platform precisely for such reasons of portability.
Free your mind
Re^3: Ensuring only one copy of a perl script is running at a time
Replies are listed 'Best First'.
I find extremely rude posts that do nothing but contradict the parent when the poster could have verified that the parent was correct.
You're wrong. flock does NOT use its own advisory locking. If flock implemented some kind of advisory locking, Windows's type command would know nothing of it, yet it can't read a file locked using flock.
use Fcntl qw( :flock );
open(my $fh, '>', 'file')
or die("Unable to open file: $!\n");
print $fh ("ok\n");
print("type without lock:\n");
or die("Unable to lock file: $!\n");
print("type with lock:\n");
It seems the point is that flock is documented to have behavior that varies between platforms. If flock is documented as always providing advisory locking, then I think that is a documentation bug (it reads to me that it certain may provide only advisory locking, but I didn't find a clear statement that manditory locking isn't the result on some platforms -- it quickly points to perlport, in fact).
So, if flock is documented to behave differently on different platforms, then writing code that depends on flock being advisory is not portable (which it obviously isn't, in practice).
It looks to me like you missed the point. And I don't see where any technical point was "just refuted" when it could have just been checked by Moron. But I certainly could be missing something.
And I don't see where any technical point was "just refuted" when it could have just been checked by Moron.
I was pointing out the root cause of the problem was that Windows usedmandatory locking. To this, he replied advisory locking was being used.
It looks to me like you missed the point.
I had no comment to make on whether flock should or shouldn't be used. I'm not sure I'd call that missing the point. I was explaining the root cause of the problem in response to someone claiming it was caused by DATA behaving differently on Windows and unix. (It doesn't.)