alain_desilets has asked for the wisdom of the Perl Monks concerning the following question:
The problem is that the last line is never printed at all! In other words, the script is not able to secure the second lock, eventhough the first lock should have been released by the closing of FILEHANDLE_1. What am I doing wrong? Note that I am running this on Windows 7. Could this be a problem with that OS? Does this script run fine on Linux? Thx. Alain Désiletsuse strict; my $fpath = 'blah.dat'; open(FILEHANDLE_1, ">", $fpath); print "Opened file '$fpath' into FILEHANDLE_1.\n"; flock(FILEHANDLE_1, 2); print "Put exclusive lock on FILEHANDLE_1\n"; close(FILE_HANDLE_1); print "Closed FILEHANDLE_1. It should now be possible to put an exclus +ive lock on file '$fpath'\n"; open(FILEHANDLE_2, ">", $fpath); print "Opened file '$fpath' into FILEHANDLE_2.\n". "Will now try to put an exclusive lock on it.\n"; flock(FILEHANDLE_2, 2); print "Successfully put exclusive lock on FILEHANDLE_2\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Can't get flock() to work. Please help...
by toolic (Bishop) on Aug 30, 2011 at 15:41 UTC | |
by alain_desilets (Beadle) on Aug 30, 2011 at 19:26 UTC | |
by GrandFather (Saint) on Aug 31, 2011 at 02:49 UTC | |
|
Re: Can't get flock() to work. Please help...
by DanielSpaniel (Scribe) on Aug 30, 2011 at 15:30 UTC | |
by alain_desilets (Beadle) on Aug 30, 2011 at 15:36 UTC |