Fix unsafe signal handler

Remove all calls to unsafe functions in signal handler.  This can help
us avoid possible (and nasty) undefined behavior when the handler calls
non-reentrant functions.
Fix log format of sig handler to better match that of logging