From: Paul Brannan Date: 2001-06-23T05:51:39+09:00 Subject: [ruby-talk:16782] strange behaviour with fork and set_trace_func After the discussion yesterday about getting the caller's binding, I've been playing with the idea of writing a caller_binding() function with pure Ruby. I'm pretty close, but I've hit an interesting roadblock: def bar(x) if not fork then set_trace_func(proc{|*a| if a[0] == "return" then # begin expr = x.to_s puts eval(expr, a[4]) # rescue Exception # puts $! # end exit! end }) else Process.wait end end def foo() bar("a") end a = 42 foo() The code above prints "42". However, if I remove the comments and catch the exception, then I get: (eval):1:in `bar': undefined local variable or method `a' for # Why am I not getting the exception when it is not explicitly caught? Paul