Odud has asked for the wisdom of the Perl Monks concerning the following question:
However when I tested it by running more than one instance the locking didn't work. Eventually by trial and error I found out that I needed to change the copy to:use strict; use File::Copy; use Fcntl ':flock'; # import LOCK_* constants my $status_file = "/tmp/flocktest"; open(STATUS, "+<$status_file") || die "Can't open file"; flock(STATUS,LOCK_EX) || die "Can't lock file"; copy("$status_file","/tmp/foo");
It looks as though copy is releasing the lock when given a filename as the first argument, but not when given a ref to the filehandle. Can anyone confirm this - and is it the expected behaviour?copy(\*STATUS,"/tmp/foo");
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: flock question
by ZZamboni (Curate) on Jun 27, 2000 at 18:20 UTC | |
by jcwren (Prior) on Jun 27, 2000 at 18:28 UTC | |
|
Re: flock question
by Odud (Pilgrim) on Jun 27, 2000 at 14:32 UTC | |
by takshaka (Friar) on Jun 28, 2000 at 06:43 UTC | |
by Odud (Pilgrim) on Jun 28, 2000 at 12:13 UTC |