From: Mike Fletcher Date: 2006-08-30T05:45:03+09:00 Subject: Re: process based locks for files Radu Spineanu wrote: > Hi, > > I have two programs accessing the same file. Both programs open and > close the file multiple times while running (for example reading it > first, and then writing it back using global functions). > > In order to avoid race conditions i was wondering if it's possible to > lock the file at the start of the running process and then unlock it at > the end. During that time the running process should be able to open and > close the file without problems. There's File#flock, but keep in mind that flock is only an advisory lock (i.e. it only notifies cooperating processes that try and get a lock themselves) and is notoriously flakey on NFS mounts. -- Posted via http://www.ruby-forum.com/.