LoginSignup
1
1

More than 5 years have passed since last update.

at_exitの重ねがけ

Posted at

at_exitって何度も設定できるんだっけ?とふと気になったので、調べてみた。

at_exit.rb
at_exit do
  puts :one
end

at_exit do
  puts :two
end

at_exit do
  puts :three
end
$ ruby at_exit.rb
three
two
one

最後に登録された順に実行されるらしい。

at_exitで補足できないのは
* Kernel#exit!したとき
* シグナルハンドラで補足できないシグナル(KILLとか)を受信したとき
* rubyがSEGVしたとき

とかだろうか。

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1