sigevent(3)

sigevent3

Asynchronous event notification

Usage

#include <signal.h>

Overview

Some operations permit threads to request asynchronous notification of events via a struct sigevent structure. This structure contains several fields that describe the requested notification:

TypeMemberDescription
intsigev_notifynotification method
intsigev_signosignal number
union sigvalsigev_valuesignal value
intsigev_notify_kqueue
unsigned shortsigev_notify_kevent_flagskevent flags
lwpid_tsigev_notify_thread_idLWP ID
void (*)(union sigval)sigev_notify_function
pthread_attr_t *sigev_notify_attributes

The sigev_notify field specifies the notification method used when the event triggers:

SIGEV_NONE

No notification is sent.

SIGEV_SIGNAL

The signal sigev_signo is queued as a real-time signal to the calling process. The value stored in sigev_value will be present in the si_value of the siginfo_t structure of the queued signal.

SIGEV_THREAD

The notification function in sigev_notify_function is called in a separate thread context. The thread is created with the attributes specified in *sigev_notify_attributes. The value stored in sigev_value is passed as the sole argument to sigev_notify_function. If sigev_notify_attributes is NULL, the thread is created with default attributes.

SIGEV_KEVENT

A new kevent is posted to the kqueue sigev_notify_kqueue. The udata member of the kevent structure contains the value stored in sigev_value. The meaning of other fields in the kevent are specific to the type of triggered event.

SIGEV_THREAD_ID

The signal sigev_signo is queued to the thread whose LWP ID is sigev_notify_thread_id. The value stored in sigev_value will be present in the si_value of the siginfo_t structure of the queued signal.

Notes

Note that programs wishing to use SIGEV_THREAD notifications must link against the library “librt”.

Releases

26 releases since FreeBSD 10.4-RELEASE; the text changed 12 times.

  1. 10.4
  2. 11.0
  3. 11.1
  4. 11.2
  5. 11.3
  6. 11.4
  7. 12.0
  8. 12.1
  9. 12.2
  10. 12.3
  11. 12.4
  12. 13.0–13.2
  13. 13.3–16.0

Standards

The struct sigevent type conforms to IEEE Std 1003.1-2004 (“POSIX.1”).

History

The sigevent structure first appeared in FreeBSD 3.3.

From base 16.0-CURRENT-20261027-61c70dc16a79 in FreeBSD 16.0-CURRENT (2026-10-27). Parsed by carta from the page's mdoc source.