diff --git a/lib/tempfile.rb b/Users/hongli/Projects/better/tempfile.rb index 752fd48..7a48603 100755 --- a/lib/tempfile.rb +++ b/Users/hongli/Projects/better/tempfile.rb @@ -82,6 +82,9 @@ class Tempfile < DelegateClass(File) MAX_TRY = 10 # :nodoc: @@cleanlist = [] @@lock = Mutex.new + + class CreationError < StandardError # :nodoc: + end # call-seq: # new(basename, [tmpdir = Dir.tmpdir], [options]) @@ -155,7 +158,7 @@ class Tempfile < DelegateClass(File) rescue failure += 1 retry if failure < MAX_TRY - raise "cannot generate tempfile `#{tmpname}'" + raise CreationError, "cannot generate tempfile `#{tmpname}'" end } @@ -304,6 +307,7 @@ class Tempfile < DelegateClass(File) def callback(data) # :nodoc: pid = $$ Proc.new { + if pid == $$ path, tmpfile, cleanlist = *data