OSDN Git Service

LDP: Update original to LDP v3.68
[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 .\" %%%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 2011-09-09 "GNU" "Linux Programmer's Manual"
27 .SH NAME
28 sigevent \- structure for notification from asynchronous routines
29 .SH SYNOPSIS
30 .nf
31
32 union sigval {          /* Data passed with notification */
33     int     sival_int;         /* Integer value */
34     void   *sival_ptr;         /* Pointer value */
35 };
36
37 struct sigevent {
38     int          sigev_notify; /* Notification method */
39     int          sigev_signo;  /* Notification signal */
40     union sigval sigev_value;  /* Data passed with
41                                   notification */
42     void       (*sigev_notify_function) (union sigval);
43                      /* Function used for thread
44                         notification (SIGEV_THREAD) */
45     void        *sigev_notify_attributes;
46                      /* Attributes for notification thread
47                         (SIGEV_THREAD) */
48     pid_t        sigev_notify_thread_id;
49                      /* ID of thread to signal (SIGEV_THREAD_ID) */
50 };
51 .fi
52 .SH DESCRIPTION
53 .PP
54 The
55 .I sigevent
56 structure is used by various APIs
57 to describe the way a process is to be notified about an event
58 (e.g., completion of an asynchronous request, expiration of a timer,
59 or the arrival of a message).
60 .PP
61 The definition shown in the SYNOPSIS is approximate:
62 some of the fields in the
63 .I sigevent
64 structure may be defined as part of a union.
65 Programs should employ only those fields relevant
66 to the value specified in
67 .IR sigev_notify .
68 .PP
69 The
70 .I sigev_notify
71 field specifies how notification is to be performed.
72 This field can have one of the following values:
73 .TP 8
74 .BR SIGEV_NONE
75 A "null" notification: don't do anything when the event occurs.
76 .TP
77 .BR SIGEV_SIGNAL
78 Notify the process by sending the signal specified in
79 .IR sigev_signo .
80 .IP
81 If the signal is caught with a signal handler that was registered using the
82 .BR sigaction (2)
83 .B SA_SIGINFO
84 flag, then the following fields are set in the
85 .I siginfo_t
86 structure that is passed as the second argument of the handler:
87 .RS 8
88 .TP 10
89 .I si_code
90 This field is set to a value that depends on the API
91 delivering the notification.
92 .TP
93 .I si_signo
94 This field is set to the signal number (i.e., the same value as in
95 .IR sigev_signo ).
96 .TP
97 .I si_value
98 This field is set to the value specified in
99 .IR sigev_value .
100 .RE
101 .IP
102 Depending on the API, other fields may also be set in the
103 .I siginfo_t
104 structure.
105 .IP
106 The same information is also available if the signal is accepted using
107 .BR sigwaitinfo (2).
108 .TP
109 .BR SIGEV_THREAD
110 Notify the process by invoking
111 .I sigev_notify_function
112 "as if" it were the start function of a new thread.
113 (Among the implementation possibilities here are that
114 each timer notification could result in the creation of a new thread,
115 or that a single thread is created to receive all notifications.)
116 The function is invoked with
117 .I sigev_value
118 as its sole argument.
119 If
120 .I sigev_notify_attributes
121 is not NULL, it should point to a
122 .I pthread_attr_t
123 structure that defines attributes for the new thread (see
124 .BR pthread_attr_init (3)).
125 .TP
126 .BR SIGEV_THREAD_ID " (Linux-specific)"
127 .\" | SIGEV_SIGNAL vs not?
128 Currently used only by POSIX timers; see
129 .BR timer_create (2).
130 .SH CONFORMING TO
131 POSIX.1-2001.
132 .SH SEE ALSO
133 .BR timer_create (2),
134 .BR aio_fsync (3),
135 .BR aio_read (3),
136 .BR aio_write (3),
137 .BR getaddrinfo_a (3),
138 .BR lio_listio (3),
139 .BR mq_notify (3),
140 .BR aio (7),
141 .BR pthreads (7)
142 .SH COLOPHON
143 This page is part of release 3.68 of the Linux
144 .I man-pages
145 project.
146 A description of the project,
147 information about reporting bugs,
148 and the latest version of this page,
149 can be found at
150 \%http://www.kernel.org/doc/man\-pages/.