From: Luis Lavena Date: 2009-08-21T17:04:17+09:00 Subject: [ruby-core:25017] Re: [Bug #1494] tempfile#unlink may silently fail on windows On Thu, Aug 20, 2009 at 8:52 PM, Yukihiro Matsumoto wrote: > Hi, > > In message "Re: [ruby-core:25011] Re: [Bug #1494] tempfile#unlink may silently fail on windows" > � �on Fri, 21 Aug 2009 08:37:35 +0900, Nobuyoshi Nakada writes: > > |At Fri, 21 Aug 2009 07:36:27 +0900, > |Shyouhei Urabe wrote in [ruby-core:25008]: > |> > |> Matz, can I revert this? �Or do you want to do so? > | > |I'd vote for Luis's suggestion. > > I am not sure what he exactly wants, and what would happen on Windows. > But if you think it's OK, please check in the fix. > Hello Matz, Basically as Jeremy Kemper pointed, the current 1.9.x implementation is flawed. On this thread: http://groups.google.com/group/rack-devel/browse_thread/thread/a2aab3a4720f34c4 A workaround is use "better" external dependency to override Ruby's one, which has been mentioned in the above thread and it's on GitHub: http://github.com/FooBarWidget/better/blob/master/lib/better/tempfile.rb#L28 More precisely, the approach shown here: http://github.com/FooBarWidget/better/blob/master/lib/better/tempfile.rb#L328-340 Seems to rescue Errno::EACCES on Windows, and silently fail. On our scenario (Windows), that will leave open descriptors. My suggestion was: if we are now taking the time to rescue that exception why we don't actually solve the issue? rescue Errno::EACCES close retry end In theory that will reduce lot of Errno:EACCES and platform specific conditions in end-users scripts. The only thing under this could fail is if another process has locked that file too. -- Luis Lavena AREA 17 - Perfection in design is achieved not when there is nothing more to add, but rather when there is nothing more to take away. Antoine de Saint-Exup�ry