From: Bertram Scharpf Date: 2006-01-12T12:16:04+09:00 Subject: Re: Calling flock with block? Hi, Am Donnerstag, 12. Jan 2006, 09:29:55 +0900 schrieb ara.t.howard@noaa.gov: > On Thu, 12 Jan 2006, Joel VanderWerf wrote: > > >It seems likely to me that a lot of people have implemented exactly that > >same piece of code, probably more than once. The #flock method doesn't > >have a block_given case already, and it's pretty unambiguous how it > >should handle that case... > > it's not needed. also, since getting a lock releases ALL other locks on the > file this needs to throw an error > > open(path,"r+") do |f| > f.flock(File::LOCK_EX) do > f.flock(File::LOCK_SH) do > # we don't have the lock here, error should be raised! > end > end > end As there's no use of nested locking it should be inhibited at all. Admittedly, file locking and all of that partially file locking is not actually the most convincing feature of Un*x ... Bertram > strong and healthy, who thinks of sickness until it strikes like lightning? > preoccupied with the world, who thinks of death, until it arrives like > thunder? -- milarepa jc did. -- Bertram Scharpf Stuttgart, Deutschland/Germany http://www.bertram-scharpf.de