exit(status=true)
Kernel::exit(status=true)
Process::exit(status=true)
Kernel::exit(status=true)
Process::exit(status=true)
Instance Public methods
Initiates the termination of the Ruby script by raising the
SystemExit
exception. This exception may be caught. The
optional parameter is used to return a status code to the invoking
environment. true
and FALSE
of status
means success and failure respectively. The interpretation of other
integer values are system dependent.
1 2 3 4 5 6 7 | begin exit puts "never get here" rescue SystemExit puts "rescued a SystemExit exception" end puts "after begin block" |
produces:
1 2 | rescued a SystemExit exception after begin block |
Just prior to termination, Ruby executes any at_exit
functions
(see Kernel::at_exit) and runs any object finalizers (see ObjectSpace.define_finalizer).
1 2 3 | at_exit { puts "at_exit function" } ObjectSpace.define_finalizer( "string" , proc { puts "in finalizer" }) exit |
produces:
1 2 | at_exit function in finalizer |
Please login to continue.