mount.2: SEE ALSO: add mount_setattr(2)
[man-pages.git] / man7 / sigevent.7
blob601e76413adc6c68550c72805d50d453b1215b9b
1 .\" Copyright (C) 2006, 2010 Michael Kerrisk <mtk.manpages@gmail.com>
2 .\" Copyright (C) 2009 Petr Baudis <pasky@suse.cz>
3 .\"
4 .\" %%%LICENSE_START(VERBATIM)
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.
24 .\" %%%LICENSE_END
25 .\"
26 .TH SIGEVENT 7 2021-03-22 "GNU" "Linux Programmer's Manual"
27 .SH NAME
28 sigevent \- structure for notification from asynchronous routines
29 .SH SYNOPSIS
30 .nf
31 #include <signal.h>
32 .PP
33 union sigval {            /* Data passed with notification */
34     int     sival_int;    /* Integer value */
35     void   *sival_ptr;    /* Pointer value */
37 .PP
38 struct sigevent {
39     int    sigev_notify;  /* Notification method */
40     int    sigev_signo;   /* Notification signal */
41     union sigval sigev_value;
42                           /* Data passed with 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
51                              (SIGEV_THREAD_ID); Linux-specific */
53 .fi
54 .SH DESCRIPTION
55 The
56 .I sigevent
57 structure is used by various APIs
58 to describe the way a process is to be notified about an event
59 (e.g., completion of an asynchronous request, expiration of a timer,
60 or the arrival of a message).
61 .PP
62 The definition shown in the SYNOPSIS is approximate:
63 some of the fields in the
64 .I sigevent
65 structure may be defined as part of a union.
66 Programs should employ only those fields relevant
67 to the value specified in
68 .IR sigev_notify .
69 .PP
70 The
71 .I sigev_notify
72 field specifies how notification is to be performed.
73 This field can have one of the following values:
74 .TP
75 .BR SIGEV_NONE
76 A "null" notification: don't do anything when the event occurs.
77 .TP
78 .BR SIGEV_SIGNAL
79 Notify the process by sending the signal specified in
80 .IR sigev_signo .
81 .IP
82 If the signal is caught with a signal handler that was registered using the
83 .BR sigaction (2)
84 .B SA_SIGINFO
85 flag, then the following fields are set in the
86 .I siginfo_t
87 structure that is passed as the second argument of the handler:
88 .RS
89 .TP 10
90 .I si_code
91 This field is set to a value that depends on the API
92 delivering the notification.
93 .TP
94 .I si_signo
95 This field is set to the signal number (i.e., the same value as in
96 .IR sigev_signo ).
97 .TP
98 .I si_value
99 This field is set to the value specified in
100 .IR sigev_value .
103 Depending on the API, other fields may also be set in the
104 .I siginfo_t
105 structure.
107 The same information is also available if the signal is accepted using
108 .BR sigwaitinfo (2).
110 .BR SIGEV_THREAD
111 Notify 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
115 each timer notification could result in the creation of a new thread,
116 or that a single thread is created to receive all notifications.)
117 The function is invoked with
118 .I sigev_value
119 as its sole argument.
121 .I sigev_notify_attributes
122 is not NULL, it should point to a
123 .I pthread_attr_t
124 structure that defines attributes for the new thread (see
125 .BR pthread_attr_init (3)).
127 .BR SIGEV_THREAD_ID " (Linux-specific)"
128 .\" | SIGEV_SIGNAL vs not?
129 Currently used only by POSIX timers; see
130 .BR timer_create (2).
131 .SH SEE ALSO
132 .BR timer_create (2),
133 .BR aio_fsync (3),
134 .BR aio_read (3),
135 .BR aio_write (3),
136 .BR getaddrinfo_a (3),
137 .BR lio_listio (3),
138 .BR mq_notify (3),
139 .BR aio (7),
140 .BR pthreads (7)