How to fill in the struct sigevent

Let's take a quick look at how you fill in the struct sigevent structure.

Regardless of the notification scheme you choose, you'll need to fill in a struct sigevent structure:

struct sigevent {
    int                             sigev_notify;
    union {
            int                     __sigev_signo;
            int                     __sigev_coid;
            int                     __sigev_id;
            void                    (*__sigev_notify_function)(union sigval);
            volatile unsigned       *__sigev_addr;
    } __sigev_un1;

    union sigval                    sigev_value;

    union {
            struct {
                    short           __sigev_code;
                    short           __sigev_priority;
            } __st;
            pthread_attr_t          *__sigev_notify_attributes;
            int                     __sigev_memop;
        } __sigev_un2;

};      
Note: Note that the above definition uses various unions and structures, but there are #define statements that make it easier for you to access the members. Check out <sys/siginfo.h> for details.

The first field you have to fill in is the sigev_notify member. This determines the notification type you've selected:

SIGEV_PULSE
A pulse will be sent.
SIGEV_SIGNAL, SIGEV_SIGNAL_CODE, or SIGEV_SIGNAL_THREAD
A signal will be sent.
SIGEV_UNBLOCK
Not used in this case; used with kernel timeouts (see “Kernel timeouts” below).
SIGEV_INTR
Not used in this case; used with interrupts (see the Interrupts chapter).
SIGEV_THREAD
Creates a thread.

Since we're going to be using the struct sigevent with timers, we're concerned only with the SIGEV_PULSE, SIGEV_SIGNAL* and SIGEV_THREAD values for sigev_notify; we'll see the other types as mentioned in the list above.