Skip to content

Commit

Permalink
Merge pull request #93 from jrochkind/workaround_mri_at_exit_bug
Browse files Browse the repository at this point in the history
workaround MRI bug in preserving exit status in at_exit
  • Loading branch information
tarcieri committed Sep 20, 2012
2 parents 7dba40a + bb9364b commit 9c038df
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion lib/celluloid.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,17 @@ def shutdown
end

# Terminate all actors at exit
at_exit { shutdown }
at_exit do
if defined?(RUBY_ENGINE) && RUBY_ENGINE == "ruby" && RUBY_VERSION >= "1.9"
# workaround for MRI bug losing exit status in at_exit block
# http://bugs.ruby-lang.org/issues/5218
exit_status = $!.status if $!.is_a?(SystemExit)
shutdown
exit exit_status if exit_status
else
shutdown
end
end

# Class methods added to classes which include Celluloid
module ClassMethods
Expand Down

0 comments on commit 9c038df

Please sign in to comment.