From: "Iñaki Baz Castillo" Date: 2011-02-02T19:46:52+09:00 Subject: Re: How to know the exit status within at_exit() block? 2011/2/1 Eric Hodel : >> Hi, my program invokes "exit true" or "exit false" and I want to catch >> such return code into at_exit() block, but I don't know how to do >> that. > > ruby -e 'at_exit { p $!.status }; exit 1' Really interesting. However, it fails if exit() is called outside of the scope: irb> at_exit { p "$!.inspect = #{$!.inspect}" } # irb> exit 1 "$!.inspect = nil" So $! is nil and I cannot get $!.status. -- Iñaki Baz Castillo