From: Eric Hodel Date: 2011-02-05T05:12:37+09:00 Subject: Re: How to know the exit status within at_exit() block? On Feb 3, 2011, at 4:13 AM, Iñaki Baz Castillo wrote: > 2011/2/3 Eric Hodel : >>> If you run this program and press Ctrl+C prior to 10 seconds you get: >>> >>> "$!.inspect = Interrupt" >>> >>> So, at_exit block is executed but $! is not a SystemExit instance. I >>> could trap the signals however. >> >> Yes, >> >> if SystemExit === $! then … end > > Thanks. I wonder if $! can be anything else apart from SystemExit and Interrupt. Yes: $ ruby -e 'at_exit { p $! }' nil $ ruby -e 'at_exit { p $! }; raise' RuntimeError -e:1: unhandled exception $