ohai / ruby-sdl2

A Ruby wrapper for SDL 2.x
GNU Lesser General Public License v3.0
72 stars 16 forks source link

Add binding for SDL_WaitEvent #17

Closed win93 closed 5 years ago

win93 commented 5 years ago

I am going to retract this pull request because SIGINT handling is broken inside of SDL2::Event.wait.

I went source diving to see how to implement correct handling, and I have narrowed down on this issue SDL_Init() calls into SDL_QuitInit (in SDL_quit.c) which only installs appropriate signal handlers if they are set to SIG_DFL. Ruby's SIGINT handler is not ideal because it will not raise interrupt from within C code.

But all that is moot because SDL_WaitEvent (in SDL_events.c) is implemented as a poll and sleep loop (yikes!), so it would be far easier to implement the same loop in ruby than to orchestrate the necessary signal handler installation dance required to make the SDL and ruby handlers coexist.