Hi,

In message "[ruby-talk:9741] Re: Possible bug in Tempfile/Fork interaction"
    on 01/01/23, "Ben Tilly" <ben_tilly / hotmail.com> writes:

|One way to resolve this would be to make the current
|pid (ie $$) be an attribute of a Tempfile and have the
|cleanup code only clean things up when $$ matches what
|the attribute.  Therefore the child would not cleanup
|the parent's temporary files.

Thanks for the information.  I hacked tempfile.rb like this:

--- lib/tempfile.rb	2000/12/08 07:10:36	1.6
+++ lib/tempfile.rb	2001/01/23 06:17:54
@@ -17,12 +17,15 @@
   def Tempfile.callback(path, data)
+    pid = $$
     lambda{
-      print "removing ", path, "..." if $DEBUG
-      data[0].close if data[0]
-      if File.exist?(path)
-	File.unlink(path) 
+      if pid == $$ 
+	print "removing ", path, "..." if $DEBUG
+	data[0].close if data[0]
+	if File.exist?(path)
+	  File.unlink(path) 
+	end
+	if File.exist?(path + '.lock')
+	  Dir.rmdir(path + '.lock')
+	end
+	print "done\n" if $DEBUG
       end
-      if File.exist?(path + '.lock')
-	Dir.rmdir(path + '.lock')
-      end
-      print "done\n" if $DEBUG
     }