Do you have a specific use-case in mind? Because I don't think this is
very useful at all; in fact it may be the opposite of useful.
Generally signals are "owned" by one particular piece of code, and if
you want to distribute the event further then you do that in the app, as
you have to do with a normal signal handler. This code is the fd-based
analog of sigtimedwait, and so it should behave basically the same way.
If multiple threads call sigtimedwait on the same signal set, then one
and only one will receive each signal. This is good, because it means
you can have a thread pool processing signals (and other events) knowing
that there won't be duplicate processing.
I haven't looked at your code in detail, but it isn't clear from your
description whether you can have multiple signalfds for different
(distinct) sets of signals. That would be useful as a first level of
demultiplexing between multiple user-mode signal consumers. If you
allow that, you need to decide whether a read/poll on a signalfd blocks
until the head queued signal is part of the signal set, or if any queued
signal is in the set.
J
-