On Mon, Jan 31, 2011 at 5:09 PM, I=F1aki Baz Castillo <ibc / aliax.net> wrote=
:

> 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.
>
> I would like something as:
>
>
> at_exit(exit_status) {
>  puts "exiting with status #{status}"
> }
>
> if SOMETHING
>  exit true
> else
>  exit false
> end
>
>
> Of course I call "exit" from lof of clases/modules under my project so
> I cannot use a local scope variable "status" (and I wouldn't like to
> use a global variable).
>
> Thanks for any suggestion.
>
> --
> I=F1aki Baz Castillo
> <ibc / aliax.net>
>
>

How about stick your own exit method before Kernel in the lookup chain

class Object
  private
  def exit(status=3Dtrue)
    at_exit {
      puts "exiting with status #{status}"
    }
    super
  end
end