From: ahoward Date: 2003-01-28T03:38:08+09:00 Subject: Re: solaris porting problem -- flock failure? On Tue, 28 Jan 2003, ts wrote: > >>>>> "a" == ahoward writes: > > a> f = File.open path, 'a+' > > The File is positionned at end of stream, if someone write in the file > when you are waiting for the lock you are not at end of stream. tricky. i wonder if the ruby flock impl could regonize this conditin based on the open mode ('a' or 'a+') and do this for you... it seems like it would never be in error. alternatively, and probably better, a new method could be added such as (incomplete example) : class File def File.flock_open (path, mode = 'r', flags = File::LOCK_SH) f = File.open path, mode while (not (f.flock flags)) Thread.pass end f.seek f.size, IO::SEEK_END if mode =~ /a\+?/ return f unless block_given? yield f f.close end end and this method could be delegated to if File.new was called with three arguements... -a -- ==================================== | Ara Howard | NOAA Forecast Systems Laboratory | Information and Technology Services | Data Systems Group | R/FST 325 Broadway | Boulder, CO 80305-3328 | Email: ahoward@fsl.noaa.gov | Phone: 303-497-7238 | Fax: 303-497-7259 ====================================