1 .\"
2 .\" This file and its contents are supplied under the terms of the
3 .\" Common Development and Distribution License ("CDDL"), version 1.0.
4 .\" You may only use this file in accordance with the terms of version
5 .\" 1.0 of the CDDL.
6 .\"
7 .\" A full copy of the text of the CDDL should have accompanied this
8 .\" source. A copy of the CDDL is also available via the Internet at
9 .\" http://www.illumos.org/license/CDDL.
10 .\"
11 .\" Copyright 2015, Joyent, Inc.
12 .\"
13 .Dd "April 9, 2016"
14 .Dt SIGNALFD 3C
15 .Os
16 .Sh NAME
17 .Nm signalfd
18 .Nd create or modify a file descriptor for signal handling
19 .Sh SYNOPSIS
20 .In sys/signalfd.h
21 .
22 .Ft int
23 .Fo signalfd
24 .Fa "int fd"
25 .Fa "const sigset_t *mask"
26 .Fa "int flags"
27 .Fc
28 .
29 .Sh DESCRIPTION
30 The
31 .Fn signalfd
32 function returns a file descriptor that can be used
33 for synchronous consumption of signals. The file descriptor can be operated
133 typedef struct signalfd_siginfo {
134 uint32_t ssi_signo; /* signal from signal.h */
135 int32_t ssi_errno; /* error from errno.h */
136 int32_t ssi_code; /* signal code */
137 uint32_t ssi_pid; /* PID of sender */
138 uint32_t ssi_uid; /* real UID of sender */
139 int32_t ssi_fd; /* file descriptor (SIGIO) */
140 uint32_t ssi_tid; /* unused */
141 uint32_t ssi_band; /* band event (SIGIO) */
142 uint32_t ssi_overrun; /* unused */
143 uint32_t ssi_trapno; /* trap number that caused signal */
144 int32_t ssi_status; /* exit status or signal (SIGCHLD) */
145 int32_t ssi_int; /* unused */
146 uint64_t ssi_ptr; /* unused */
147 uint64_t ssi_utime; /* user CPU time consumed (SIGCHLD) */
148 uint64_t ssi_stime; /* system CPU time consumed (SIGCHLD) */
149 uint64_t ssi_addr; /* address that generated signal */
150 uint8_t ssi_pad[48]; /* pad size to 128 bytes */
151 } signalfd_siginfo_t;
152 .Ed
153 .Sh RETURN VALUES
154 Upon successful completion, a file descriptor associated with the instance
155 is returned. Otherwise, -1 is returned and errno is set to indicate the error.
156 When
157 .Va fd
158 is not -1 and there is no error, the value of
159 .Va fd
160 is returned.
161 .Sh ERRORS
162 The
163 .Fn signalfd function
164 will fail if:
165 .Bl -tag -width Er
166 .It Er EBADF
167 The
168 .Va fd
169 descriptor is invalid.
170 .It Er EFAULT
171 The
172 .Va mask
173 address is invalid.
174 .It Er EINVAL
175 The
176 .Va fd
177 descriptor is not a signalfd descriptor or the
178 .Va flags
179 are invalid.
180 .It Er EMFILE
181 There are currently
182 .Va OPEN_MAX
183 file descriptors open in the calling process.
184 .It Er ENODEV
185 Unable to allocate state for the file descriptor.
186 .El
187 .Sh SEE ALSO
188 .Xr poll 2 ,
189 .Xr sigwait 2 ,
190 .Xr sigsetops 3C ,
191 .Xr sigwaitinfo 3C ,
192 .Xr signal.h 3HEAD
|
1 .\"
2 .\" This file and its contents are supplied under the terms of the
3 .\" Common Development and Distribution License ("CDDL"), version 1.0.
4 .\" You may only use this file in accordance with the terms of version
5 .\" 1.0 of the CDDL.
6 .\"
7 .\" A full copy of the text of the CDDL should have accompanied this
8 .\" source. A copy of the CDDL is also available via the Internet at
9 .\" http://www.illumos.org/license/CDDL.
10 .\"
11 .\" Copyright 2016, Joyent, Inc.
12 .\"
13 .Dd "May 05, 2016"
14 .Dt SIGNALFD 3C
15 .Os
16 .Sh NAME
17 .Nm signalfd
18 .Nd create or modify a file descriptor for signal handling
19 .Sh SYNOPSIS
20 .In sys/signalfd.h
21 .
22 .Ft int
23 .Fo signalfd
24 .Fa "int fd"
25 .Fa "const sigset_t *mask"
26 .Fa "int flags"
27 .Fc
28 .
29 .Sh DESCRIPTION
30 The
31 .Fn signalfd
32 function returns a file descriptor that can be used
33 for synchronous consumption of signals. The file descriptor can be operated
133 typedef struct signalfd_siginfo {
134 uint32_t ssi_signo; /* signal from signal.h */
135 int32_t ssi_errno; /* error from errno.h */
136 int32_t ssi_code; /* signal code */
137 uint32_t ssi_pid; /* PID of sender */
138 uint32_t ssi_uid; /* real UID of sender */
139 int32_t ssi_fd; /* file descriptor (SIGIO) */
140 uint32_t ssi_tid; /* unused */
141 uint32_t ssi_band; /* band event (SIGIO) */
142 uint32_t ssi_overrun; /* unused */
143 uint32_t ssi_trapno; /* trap number that caused signal */
144 int32_t ssi_status; /* exit status or signal (SIGCHLD) */
145 int32_t ssi_int; /* unused */
146 uint64_t ssi_ptr; /* unused */
147 uint64_t ssi_utime; /* user CPU time consumed (SIGCHLD) */
148 uint64_t ssi_stime; /* system CPU time consumed (SIGCHLD) */
149 uint64_t ssi_addr; /* address that generated signal */
150 uint8_t ssi_pad[48]; /* pad size to 128 bytes */
151 } signalfd_siginfo_t;
152 .Ed
153 .Sh NOTES
154 File descriptor duplication during fork presents a challenge to the
155 .Sy signalfd
156 facility since signal data and events are dependent on the process from which
157 they are queried. Its use with caching event systems such as
158 .Xr epoll 5 ,
159 .Sy /dev/poll ,
160 or
161 .Xr port_create 3C
162 can result in undefined behavior if signalfd and polling descriptors are used
163 together after being shared across a fork. Such restrictions do not apply if
164 the child only calls
165 .Xr close 2
166 on the descriptors.
167 .Sh RETURN VALUES
168 Upon successful completion, a file descriptor associated with the instance
169 is returned. Otherwise, -1 is returned and errno is set to indicate the error.
170 When
171 .Va fd
172 is not -1 and there is no error, the value of
173 .Va fd
174 is returned.
175 .Sh ERRORS
176 The
177 .Fn signalfd function
178 will fail if:
179 .Bl -tag -width Er
180 .It Er EBADF
181 The
182 .Va fd
183 descriptor is invalid.
184 .It Er EFAULT
185 The
186 .Va mask
187 address is invalid.
188 .It Er EINVAL
189 The
190 .Va fd
191 descriptor is not a signalfd descriptor or the
192 .Va flags
193 are invalid.
194 .It Er EMFILE
195 There are currently
196 .Va OPEN_MAX
197 file descriptors open in the calling process.
198 .It Er ENODEV
199 Unable to allocate state for the file descriptor.
200 .El
201 .Sh SEE ALSO
202 .Xr poll 2 ,
203 .Xr sigwait 2 ,
204 .Xr port_create 3C ,
205 .Xr sigsetops 3C ,
206 .Xr sigwaitinfo 3C ,
207 .Xr signal.h 3HEAD ,
208 .Xr epoll 5
|