* Use of SIGUSR2 to interrupt select() does not work because signals
which arrive just before entry to select() do not interrupt it.
* The sigwait approach to detecting aio does not work properly because
some versions of glibc forget to block signals on the private aio
thread under some hard-to-reproduce conditions. This means that
blocking SIGUSR2 is ineffective; the signals can be lost and the
program can block in sigwait (!)
So instead we use the time-honoured self-pipe trick: in the signal
handler we write to a pipe, which we select on when we want to wait
for the signal, and which we read from (to empty out) just before
actually doing the `top half' processing which deals with the condition
to which the signal relates.
We use the existing fd handler infrastructure to run the desired
completion code out of the main event loop; in the aio completion wait
we use a cut-down version of the same arrangements.