struct sigevent is not about defining how the signal is processed - struct sigaction and sigaction() - how you do it. Instead, struct sigevent used to indicate how your process will be informed of any asynchronous event — for example, asynchronous I / O completion or timer expiration.
The sigev_notify field indicates how the event should be notified:
SIGEV_NONE - no notification at all. The remaining fields are ignored.SIGEV_SIGNAL - a signal is sent to the process. The sigev_signo field indicates the signal, the sigev_value field contains additional data that is passed to the signal processing function, and the remaining fields are ignored.SIGEV_THREAD - the function is called in a new thread. The sigev_notify_function field indicates the function that is being called, sigev_value contains additional data that is passed to the function, and sigev_notify_attributes indicates the attributes of the streams to use to create the stream. The remaining fields are ignored.
Note, in particular, that if you set SIGEV_THREAD , the sigev_signo field sigev_signo ignored - struct sigevent indicates neither a stream nor a signal as a notification method, but not as a stream as the way the signal should be processed.
struct sigevent should also be passed to a function - like timer_create() - that sets an asynchronous event to be notified. Just creating a struct sigevent object does nothing special.
If you want to use a dedicated stream to process the signal, create a stream up and run it by blocking sigwaitinfo() . Use sigprocmask() to block the signal in each other thread.
source share