Refactor signal handling to happen outside of trap context.

Signal handling is done at one second intervals using an EM timer.