From: Daniel Berger Date: 2007-04-25T05:54:32+09:00 Subject: Re: Question about tempfile.rb - Ruby vs C On 4/24/07, Tim Pease wrote: > On 4/24/07, Daniel Berger wrote: > > Hi all, > > > > Just curious - why was Ruby's temporary file handling class > > (tempfile.rb) written in pure Ruby instead of using the tmpfile() > > function? That function appears to be supported on most platforms, > > including MS Windows. > > > > Are there file locking or threading issues I'm not aware of? > > > > The tmpfile() function does have the advantage of deleting itself when > > all references to it are gone, instead of waiting until the Ruby > > process itself dies. Perhaps there's no real advantage to that, > > though? > > > > The Ruby Tempfile class creates a finalizer that will delete the temp > file when it is collected by the garbage collector; the Ruby Tempfile > also deletes the temp file when it is closed. Your paragraph above > makes it sound like this is not the case. I was basing my comment on the Pickaxe 2, p. 741 which says, "...temporary files are automatically deleted when the Ruby process terminates". Regards, Dan