in reply to use die with flock

Well, it's never necessary to use die after an open. You ought to check the return value of open, and do something appropriate if it fails. For many programs, a die is appropriate.

Having said that, a flock is just a flock. Most systems don't have manditory locks, and a flock on a file does not prevent it to be opened. In fact, a flock on the file doesn't prevent it to be read, or written to. Multiple processes accessing a file do have to cooperate using flock, but if a process decides not to, you are out of luck.

How systems work that have manditory file locking, with respect to open, I do not know.

Abigail

Replies are listed 'Best First'.
Re: Re: use die with flock
by Limbic~Region (Chancellor) on Jul 24, 2003 at 15:47 UTC
    Abigail,
    I am not going to pretend to be authoratitive here, but I believe your very well written synopsis is true for *nix systems but not all operating systems. I believe file locking is more integrated into the OS for Win32 systems since you can't delete a locked file there where you can in *nix.

    Cheers - L~R

    Update: I didn't originally notice the word most which makes everything Abigail says valid. It is important to either write portable code that will behave correctly in all environments, or make the limitations of the code to a target platform well known.