# Reliability of flock mutex (LOCK_EX|LOCK_NB)

I would like to test reliability of system flock in a multi-threaded and concurrent environment as some suggest that they are not reliable (in comments).

Thus I wrote this code which requests non-blocking exclusive lock, with multiple threads at the same time (well, almost same time).

Is there better way to test flock mutex functionality, or how to be sure that it is always exclusive?

use strict;
use warnings;
use autodie;

sub fo{ my $fh; open($fh, ">", pop) && $fh } my$t = time();
my $one = grep$_->join,
my $f = fo("/tmp/flock.test"); sleep 2+$t-time();
my $l = flock($f, LOCK_EX|LOCK_NB);
return $l; }, 1..90; # should always be 1 print "$one is 1\n";