The functions "[fprintf](http://pubs.opengroup.org/onlinepubs/9699919799/functions/fprintf.html)" and "[erase](http://linux.die.net/man/3/erase)" do not belong to the list of [async-signal-safe functions](https://www.securecoding.cert.org/confluence/display/seccode/SIG30-C.+Call+only+asynchronous-safe+functions+within+signal+handlers). I guess that a different program design will be needed for your function "[engine_safe_exit](https://github.com/alexdantas/yetris/blob/a40c5f3dff5a88c653b2c78b5327e17f44d1ad46/src/engine.c#L409)".