in reply to Re: mkfifo/mknode
in thread mkfifo/mknode

Hello Moron, I tried to use the flock function but i got the error - Usage: Fcntl::constant(name, arg) at Fcntl.pm line 225. Do you have any simple example ? Thanks

Replies are listed 'Best First'.
Re^3: mkfifo/mknode
by Moron (Curate) on Jun 14, 2006 at 14:02 UTC
    Here is a simple example of using a dedicated lock file
    my $LOCK_EX = 2; # exclusive lock on file my $LOCK_UN = 8; # unlock file my $lock_file = $ENV{ XYZ_DIR } . "/$0.lock"; open my $lh, ">$lock_file" || die "Can't open lock file $lock_file: $! +"; flock $lh, $LOCK_EX; # will wait for exclusive lock # on lock file # do the exclusive actions flock $lh, $LOCK_UN; close $lh;

    -M

    Free your mind