News for hackers. Stuff that matters.
Re:All about Linux signals - Linux Programming Blog by caf on Monday April 02, 2012 @07:50PM (#3790753)
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).

Re:All about Linux signals - Linux Programming Blog by emmelaich on Monday April 02, 2012 @10:42PM (#3791210)
I believe this is referred to as the 'self pipe' trick. Dan Bernstein says he came up with it in 1990.

http://cr.yp.to/docs/selfpipe.html

Re:All about Linux signals - Linux Programming Blog by gchpaco on Monday April 02, 2012 @09:59PM (#3791113)
That's a good point, and what I actually did last time this came up. signalfd on Linux just codifies this convention, but it is (particularly in evented code) an excellent idea.