How does ruby ​​rb_raise stop the c function calling it?

If you write a ruby ​​method as a function in C that uses rb_raise, part of the function after the call will not be canceled, and the program will stop, and you will think that it is rb_raiseused exit(). But if you choose an exception in ruby, for example:

begin
  method_that_raises_an_exception
rescue
end
puts 'You wil still get here.'

The ruby ​​code will continue, but your function will stop excecuting. How to do it rb_raise?

+5
source share
1 answer

Presumably it uses setjmp(before calling the method) and longjmp(c rb_raise).

+5
source

All Articles