OSDN Git Service

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