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... i sure have. on the otherhand it is generally redundant since closing the file is guaranteed to release the lock... so unless you need open(path,"r+") do |f| f.flock(File::LOCK_EX) do ... end f.something end 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 child processes also affect lock so this should also throw open(path,"r+") do |f| f.flock(File::LOCK_EX) do fork do f.flock(File::LOCK_EX) do ... end end # we don't have the lock here, error should be raised! end end in the end i think it may be wise no allow applications to simply use ensure where needed - a 'correct' impl is rather tricky. regards. -a -- 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