digitalhack/openFrameworks — pull request #8 by fieldOfView (2014-02-28 13:08:28+00:00)
Title: Fix exiting the app with SIGINT or SIGTERM

Compiled apps do not exit cleanly when sent a SIGINT (eg Ctrl-c from ssh) or SIGTERM (eg kill from ssh). Pressing the Esc key on the console (usb keyboard) does exit the app cleanly. Stuck apps can be force-quit with SIGKILL (eg kill -9 from ssh)

The app gets stuck in ofAppEGLWindow::destroySurface() on the call to eglDestroySurface(eglDisplay, eglSurface); Unfortunately, this lands us into binary blob territory which we cannot fix.

This patch works around the issue by not using exitApp() directly and mid-frame, but instead signalling ofAppEGLWindow::runAppViaInfiniteLoop to gracefully end the loop. This seems to work more reliably than using exitApp() in the middle of frame execution.

Exiting the app using the Esc key on an external keyboard is unchanged, as is using exitApp() from code.