Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Perl Beginners > flock - exclusi...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 5 Topic 10752 of 11992
Post > Topic >>

flock - exclusive file locking

by paikkos@[EMAIL PROTECTED] (Dermot) Mar 17, 2008 at 08:47 PM

------=_Part_18148_20360767.1205786865011
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

Hi,

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"

The worst part about this problem is that it seems completely erratic.
Sometimes the string is written to the file and sometimes not. Sometimes I
get an error and sometimes not but it never dies and the user will think
the
data has been written to file! Does anyone see something wrong with the
snippet above or have any insights on file-clocking they could offer.

Thanx,
Dp.

------=_Part_18148_20360767.1205786865011--
 




 5 Posts in Topic:
flock - exclusive file locking
paikkos@[EMAIL PROTECTED]  2008-03-17 20:47:44 
Re: flock - exclusive file locking
rvtol+news@[EMAIL PROTECT  2008-03-17 22:39:26 
Re: flock - exclusive file locking
noreply@[EMAIL PROTECTED]  2008-03-17 22:49:43 
Re: flock - exclusive file locking
krahnj@[EMAIL PROTECTED]   2008-03-17 15:33:49 
Re: flock - exclusive file locking
chas.owens@[EMAIL PROTECT  2008-03-18 16:57:30 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Mon Oct 13 11:18:31 CDT 2008.