Re: File locking issue



On 8/31/06, Nath, Alok (STSD) <alok.nath@xxxxxx> wrote:

What I am seeing is when I enable the file locking commands
the file is completely wiped out.Just zero bytes.

#use lock to write into the file
sysopen( FH, $registerFile, O_RDWR )
or die "can't open $registerFile: $!";
flock( FH, LOCK_EX)
or die "can't lock filename: $!";
truncate(FH, 0) or die "can't truncate filename: $!";

I think I know where the "zero bytes" are coming from. :-)

$twig->parsefile( $registerFile );

What are you hoping to parse from the file that you've just truncated
to zero bytes?

Hope this helps!

--Tom Phoenix
Stonehenge Perl Training
.



Relevant Pages

  • Re: File locking issue
    ... the file is completely wiped out.Just zero bytes. ... But it works correctly when I remove the file locking commands. ... #use lock to write into the file ... flock() locks the file, it is NOT changing the size. ...
    (perl.beginners)
  • Re: More ATC Confusion Near Phoenix
    ... zero three eight radial descend and maintain one zero thousand. ... Phoenix and I don't see how I'm going to intercept the zero three ... I can't explain the clearance confusion. ...
    (rec.aviation.ifr)
  • test msg
    ... MBA HCM program Univ of Phoenix ... Ground below Zero, City of New Orleans, La ...
    (rec.heraldry)
  • Re: Check if a given function returns something
    ... I meant that "return" called alone simply gives you a zero. ... return gives the sub's caller either undef or an ... empty list, depending upon context. ... Stonehenge Perl Training ...
    (perl.beginners)