tye, Thanks for the input. I tried your suggestion, and when configured as you suggest, the flock dies with the message "Resource temporarily unavailable". Wow. What does
that mean? I mean, it says what it says, yeah. But what does it really mean, in terms of flocking? It's quite strange. When I made a temp directory of my own "/home/username/htdocs/tmp" and made it chmod 777, it was able to flock just fine.
So is there an issue with flocking files which are not in your own userspace (i.e. /tmp or something), perhaps?
Update: Incidentally, I got this very same result with the script on two different machines: one running Slack 7, and the other running FreeBSD 3.1
Update 2: I just had to try the simplest version, so I did this:
#!/usr/bin/perl
use Fcntl qw( :flock );
my $tempfile="/tmp/$$.temp";
print "Content-type: text/html\n\n";
print "Testing flocking now.<BR>\n";
open(TMP, "+> $tempfile") or die "Could not open tempfile: $!";
flock(TMP, LOCK_EX|LOCK_NB) or die "no lock: $!";
seek(TMP, 0, 0);
print TMP "Blah blah blah"; # just to test
close(TMP);
unlink $tempfile;
print "That seemed to go just fine.\n";
And it ran just fine. Go figure. I'm quite puzzled.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.