The best thing to do in a signal handler is often to write() a single byte to a pipe.
Your main loop can then notice that the other end of the pipe is readable (the main loop is normally watching file descriptors for activity anyway).
Your main loop can then notice that the other end of the pipe is readable (the main loop is normally watching file descriptors for activity anyway).