Hi,
In message "[ruby-talk:16782] strange behaviour with fork and set_trace_func"
on 01/06/23, Paul Brannan <pbrannan / atdesk.com> writes:
|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:
OK, let me explain. This was an ineresting puzzle.
|(eval):1:in `bar': undefined local variable or method `a' for
|#<Object:0x40282c90>
Above exception was raised anyway. The first "return" event, the
binding given was one within "foo", so you couldn't get the value of
"a", which wasn't belong there. So exception termitated the
trace_func, then "foo". After that, the second "return" event, which
was for "foo" was called. This time, you could get top level binging
so that you got the value of "a".
When you removed the comment, you captured the first exception, then
terminated the whole child process. You didn't give the chance to the
second "return" event to show you the value of "a".
matz.