[review] Signal handlers cleanup

Calling log_message() inside a signal handler is unsafe [because it includes calls to malloc()](http://stackoverflow.com/questions/3366307/why-is-malloc-not-async-signal-safe). See also [this very nice page](https://www.securecoding.cert.org/confluence/display/seccode/SIG30-C.+Call+only+asynchronous-safe+functions+within+signal+handlers)

This removes most of those log_message() calls, replacing them with safe logging instead when required.

WIP. Considering adding fancy stack traces to it. May be squashed later.
Calling `write()` from the signal handler might end badly?