我想使用独占/共享的阻塞和非阻塞原子锁,就像flock()
.
use strict;
use warnings;
use Fcntl qw(:flock);
open my $fh, ">", "/tmp/lockf" or die $!;
# one of LOCK_EX, LOCK_EX|LOCK_NB, LOCK_SH, LOCK_SH|LOCK_NB
my $lock_mode = LOCK_EX;
flock($fh, $lock_mode) or die $!;
如何使用信号量来实现此功能?