in reply to •Re: Update in-place with temporary file and flocking
in thread Update in-place with temporary file and flocking

What's worrying me is that I'll be half way through reading the file whilst it's swapped out from under me. I don't see how that code changes things - but I'm probably missing something.
  • Comment on Re: •Re: Update in-place with temporary file and flocking

Replies are listed 'Best First'.
•Re: Re: •Re: Update in-place with temporary file and flocking
by merlyn (Sage) on Feb 18, 2004 at 17:25 UTC
    Once you have the file open, renaming it doesn't matter. The only problem is if someone edits the very file you have open, and the referenced code ensures that this never happens. That's what's nice about an atomic rename operation.

    -- Randal L. Schwartz, Perl hacker
    Be sure to read my standard disclaimer if this is a reply.

      See my update, is it always ok, or just on UNIX style systems where the filehandle actually points at the file descriptor, rather than just refering to the file by name. Obviously if it's just referring by name then a rename breaks things, and the another instance of the script can't know that the file is actually locked, can it?