]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man7/sigevent.7
signal.7: Some reworking of Michal Sekletar's text
[thirdparty/man-pages.git] / man7 / sigevent.7
CommitLineData
bcc5e407
PB
1.\" Copyright (C) 2006, 2010 Michael Kerrisk <mtk.manpages@gmail.com>
2.\" Copyright (C) 2009 Petr Baudis <pasky@suse.cz>
3.\"
93015253 4.\" %%%LICENSE_START(VERBATIM)
bcc5e407
PB
5.\" Permission is granted to make and distribute verbatim copies of this
6.\" manual provided the copyright notice and this permission notice are
7.\" preserved on all copies.
8.\"
9.\" Permission is granted to copy and distribute modified versions of this
10.\" manual under the conditions for verbatim copying, provided that the
11.\" entire resulting derived work is distributed under the terms of a
12.\" permission notice identical to this one.
13.\"
14.\" Since the Linux kernel and libraries are constantly changing, this
15.\" manual page may be incorrect or out-of-date. The author(s) assume no
16.\" responsibility for errors or omissions, or for damages resulting from
17.\" the use of the information contained herein. The author(s) may not
18.\" have taken the same level of care in the production of this manual,
19.\" which is licensed free of charge, as they might when working
20.\" professionally.
21.\"
22.\" Formatted or processed versions of this manual, if unaccompanied by
23.\" the source, must acknowledge the copyright and authors of this work.
4b72fb64 24.\" %%%LICENSE_END
bcc5e407 25.\"
f55a6d59 26.TH SIGEVENT 7 2017-07-13 "GNU" "Linux Programmer's Manual"
bcc5e407 27.SH NAME
5b64c2d1 28sigevent \- structure for notification from asynchronous routines
bcc5e407
PB
29.SH SYNOPSIS
30.nf
0b8f560a 31#include <signal.h>
dbfe9c70 32.PP
bcc5e407
PB
33union sigval { /* Data passed with notification */
34 int sival_int; /* Integer value */
35 void *sival_ptr; /* Pointer value */
36};
dbfe9c70 37.PP
bcc5e407
PB
38struct sigevent {
39 int sigev_notify; /* Notification method */
40 int sigev_signo; /* Notification signal */
41 union sigval sigev_value; /* Data passed with
42 notification */
43 void (*sigev_notify_function) (union sigval);
44 /* Function used for thread
45 notification (SIGEV_THREAD) */
46 void *sigev_notify_attributes;
47 /* Attributes for notification thread
48 (SIGEV_THREAD) */
49 pid_t sigev_notify_thread_id;
50 /* ID of thread to signal (SIGEV_THREAD_ID) */
51};
52.fi
53.SH DESCRIPTION
54.PP
55The
56.I sigevent
57structure is used by various APIs
58to describe the way a process is to be notified about an event
59(e.g., completion of an asynchronous request, expiration of a timer,
60or the arrival of a message).
61.PP
62The definition shown in the SYNOPSIS is approximate:
63some of the fields in the
64.I sigevent
65structure may be defined as part of a union.
33a0ccb2 66Programs should employ only those fields relevant
bcc5e407
PB
67to the value specified in
68.IR sigev_notify .
69.PP
70The
71.I sigev_notify
72field specifies how notification is to be performed.
73This field can have one of the following values:
74.TP 8
75.BR SIGEV_NONE
76A "null" notification: don't do anything when the event occurs.
77.TP
78.BR SIGEV_SIGNAL
79Notify the process by sending the signal specified in
80.IR sigev_signo .
81.IP
82If the signal is caught with a signal handler that was registered using the
83.BR sigaction (2)
84.B SA_SIGINFO
85flag, then the following fields are set in the
86.I siginfo_t
87structure that is passed as the second argument of the handler:
88.RS 8
89.TP 10
90.I si_code
91This field is set to a value that depends on the API
92delivering the notification.
93.TP
94.I si_signo
f6b326eb 95This field is set to the signal number (i.e., the same value as in
bcc5e407
PB
96.IR sigev_signo ).
97.TP
98.I si_value
99This field is set to the value specified in
100.IR sigev_value .
101.RE
102.IP
103Depending on the API, other fields may also be set in the
104.I siginfo_t
105structure.
106.IP
107The same information is also available if the signal is accepted using
108.BR sigwaitinfo (2).
109.TP
110.BR SIGEV_THREAD
111Notify the process by invoking
112.I sigev_notify_function
113"as if" it were the start function of a new thread.
114(Among the implementation possibilities here are that
115each timer notification could result in the creation of a new thread,
116or that a single thread is created to receive all notifications.)
117The function is invoked with
118.I sigev_value
119as its sole argument.
120If
121.I sigev_notify_attributes
122is not NULL, it should point to a
123.I pthread_attr_t
124structure that defines attributes for the new thread (see
125.BR pthread_attr_init (3)).
126.TP
127.BR SIGEV_THREAD_ID " (Linux-specific)"
128.\" | SIGEV_SIGNAL vs not?
129Currently used only by POSIX timers; see
130.BR timer_create (2).
47297adb 131.SH SEE ALSO
bcc5e407
PB
132.BR timer_create (2),
133.BR aio_fsync (3),
a9ba82d5
MK
134.BR aio_read (3),
135.BR aio_write (3),
0f848cbc 136.BR getaddrinfo_a (3),
3e5c319e 137.BR lio_listio (3),
bcc5e407 138.BR mq_notify (3),
9889b88b 139.BR aio (7),
bcc5e407 140.BR pthreads (7)