문제

I have a Rails application with a FFI binding to a custom RPC system. Unfortunately, the C code calls exit() when it is unable to connect to the RPC server, terminating the entire Rails application.

Is it possible to trap calls to exit() in Ruby? I'd rather not have to change the C code.

도움이 되었습니까?

해결책

You cannot trap a function call. However maybe you can link the C code with a dummy exit() function that will not actually exit.

The cleaner solution is by far to change the C code to give it a proper library behaviour.

You could also fork in ruby before doing the RPC call, a bit on the expensive side performance wise but would solve the issue too...

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top