SIGEVENT(3)

πŸ“¦
version 15.1 Β· 2 versions
, in freebsd 14.5, freebsd 15.1, nixpkgs unstable

πŸ¦‹ SIGEVENT(3) β€” asynchronous event notification, from the Library Functions Manual πŸ¦‹

✨ NAME ✨

sigevent β€” asynchronous event notification. that's the name, bestie, and it's iconic. πŸ’…

🌈 SYNOPSIS 🌈

the one include you need:

#include <signal.h>

πŸ’– DESCRIPTION πŸ’–

okay so 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 β€” and the way that this struct lays out its fields? obsessed. no cap, every single one matters:

  • int sigev_notify β€” notification method
  • int sigev_signo β€” signal number
  • union sigval sigev_value β€” signal value
  • int sigev_notify_kqueue β€” kqueue(2) file descriptor
  • unsigned short sigev_notify_kevent_flags β€” kevent flags
  • lwpid_t sigev_notify_thread_id β€” LWP ID
  • void (*)(union sigval) sigev_notify_function β€” callback function pointer
  • pthread_attr_t * sigev_notify_attributes β€” callback thread attributes

the sigev_notify field specifies the notification method used when the event triggers: lowkey choose your fighter πŸŽ€

  • SIGEV_NONE β€” no notification is sent. literally ghost mode, not me sending nothing. πŸ‘»
  • 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. signal delivery said hi. πŸ“¬
  • 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. thread behavior, slay. 🧡
  • 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. kqueue girlies rise. 🌊
  • 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. specific-thread delivery, periodt. 🎯

🚨 NOTES 🚨

note note note: programs wishing to use SIGEV_THREAD notifications must link against the POSIX Real-time Library (librt, -lrt). do not forget the link, bestie β€” iykyk. 😭

πŸ”— SEE ALSO πŸ”—

go peek at aio_read(2), mq_notify(2), timer_create(2), and siginfo(3). the whole friend group. 🫢

πŸ“œ STANDARDS πŸ“œ

the struct sigevent type conforms to IEEE Std 1003.1-2004 (β€œPOSIX.1”). standardized and stunning. ✨

πŸ¦‹ HISTORY πŸ¦‹

the sigevent structure first appeared in FreeBSD 3.3. that's the origin story, fr fr. πŸ’œ


πŸ’– and that's the page, bestie β€” it's from Debian, dated February 25, 2020, and it's the SIGEVENT(3) page. mwah! πŸŽ€

πŸ“¦ where this page comes from