Refactor tor's signal handler to avoid undefined behaviour
A signal handler can be called at any time, including when Tor's data structures are in an inconsistent state.
The C standard says that setting anything other than a sig_atomic_t flag in a signal handler is undefined behaviour. POSIX is slightly more permissive, but we still do far too much in our signal handler.
Could we set flags and check them at the top of the event loop instead? Or are there things we must handle right away?