Dermot wrote:
I have a cgi script that writes to a disk file. It would be safest if I can
get an exclusive lock on the file. I had a look at the opentut and believe I
have followed that the example there. Here's what I have
sysopen my $fh, $file_path, O_WRONLY || die "can't open
$file_path: $!\n";
flock($fh,LOCK_EX) or die "can't lock $file_path: $!\n";
seek($fh, 0, 2); # Append to file
print $fh $status."\n";
print STDERR "$0: $! $?\n";
close($fh);
I am getting the error
"Inappropriate ioctl for device 0"
Even if I can't reproduce that error, I see one thing that is not correct.
sysopen my $fh, $file_path, O_WRONLY || die ...
That is interpreted as
sysopen my $fh, $file_path, (O_WRONLY || die ... )
i.e. the script will never die at that line, since the constant O_WRONLY
is always true. You need to do either
sysopen( my $fh, $file_path, O_WRONLY ) || die ...
-----------^------------------------------^
or
sysopen my $fh, $file_path, O_WRONLY or die ...
-----------------------------------------^^
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/