#! /usr/bin/perl -w

$l1 = "/misc/wintmp/0/link0";
$l2 = "/misc/wintmp/1/link1";

use Fcntl qw(:DEFAULT :flock);
open FH1A, '>', $l1 or die "can't open $l1(a)";
open FH1B, '>', $l1 or die "can't open $l1(b)";
open FH2, '>', $l2 or die "can't open $l2";

print flock(FH1A, LOCK_EX | LOCK_NB) ?
    "$l1(a): successfully locked exclusive\n" :
    "$l1(a): failed to lock exclusive\n";

print flock(FH1B, LOCK_EX | LOCK_NB) ?
    "$l1(b): successfully locked exclusive\n" :
    "$l1(b): failed to lock exclusive\n";

print flock(FH2, LOCK_EX | LOCK_NB) ?
    "$l2: successfully locked exclusive\n" :
    "$l2: failed to lock exclusive\n";

close FH1A;
close FH1B;
close FH2;
