Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Flock, Seek & WinNT

by meetraz (Hermit)
on Dec 30, 2002 at 16:14 UTC ( [id://223064] : note . print w/replies, xml ) Need Help??


in reply to Flock, Seek & WinNT

I use flock() on winnt on a regular basis, and it works exactly as you'd expect. Once one script has it flock()'d the others will block until it becomes available, and each script takes its turn.

Replies are listed 'Best First'.
Re^2: Flock, Seek & WinNT (not advisory)
by tye (Sage) on Dec 30, 2002 at 19:08 UTC

    Note that flock() under Win32 is more like the (non-default) mandatory locking in Unix than like regular advisory locking.

    This means that having a lock on a file in Win32 can prevent other processes from reading from or writing to the file (I used to think it even prevented opening but my current testing says otherwise so this might depend on the version of Win32 or...).

    What you might find even more surprising is that having a lock on one file handle can prevent the same process from reading from or writing to that file via a different file handle.

                    - tye (you have been warned)
Re: Re: Flock, Seek & WinNT
by meetraz (Hermit) on Dec 30, 2002 at 16:14 UTC
    Oh, and the same goes for seek()