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
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.
11 .\" Copyright 2016, Joyent, Inc.
18 .Nd create or modify a file descriptor for signal handling
25 .Fa "const sigset_t *mask"
32 function returns a file descriptor that can be used
33 for synchronous consumption of signals.
34 The file descriptor can be operated upon via
36 and the facilities that notify of file descriptor activity (e.g.
41 To dispose of the instance
43 should be called on the file descriptor.
47 argument is -1, a new signalfd file descriptor will be
48 returned, otherwise the
50 argument should be an existing signalfd file descriptor whose signal mask will
55 argument specifies the set of signals that are relevant to the file descriptor.
56 It may be manipulated with the standard signal set manipulation functions
59 Signals in the mask which cannot be caught (e.g.
65 argument specifies additional parameters for the instance, and can have any of
69 Instance will be closed upon an
76 Instance will be set to be non-blocking.
79 on a signalfd instance that has been initialized with
81 or made non-blocking in other ways, will return
83 in lieu of blocking if there are no signals from the
90 reading a signal from the file descriptor will consume the signal.
91 The signals used with signalfd file descriptors are normally first blocked so
92 that their handler does not run when a signal arrives.
93 If the signal is not blocked the behavior matches that of
97 is pending then the signal is consumed by the read, otherwise the signal is
98 consumed by the handler.
100 The following operations can be performed upon a signalfd file descriptor:
103 Reads and consumes one or more of the pending signals that match the file
106 The read buffer must be large enough to hold one or more
108 structures, which is described below.
110 will block if there are no matching signals pending, or return
112 if the instance was created with
116 if the child reads from the descriptor it will only consume signals from itself.
118 Provide notification when one of the signals from the
126 Closes the desriptor.
131 structure returned from
133 is a fixed size 128 byte structure defined as follows:
135 typedef struct signalfd_siginfo {
136 uint32_t ssi_signo; /* signal from signal.h */
137 int32_t ssi_errno; /* error from errno.h */
138 int32_t ssi_code; /* signal code */
139 uint32_t ssi_pid; /* PID of sender */
140 uint32_t ssi_uid; /* real UID of sender */
141 int32_t ssi_fd; /* file descriptor (SIGIO) */
142 uint32_t ssi_tid; /* unused */
143 uint32_t ssi_band; /* band event (SIGIO) */
144 uint32_t ssi_overrun; /* unused */
145 uint32_t ssi_trapno; /* trap number that caused signal */
146 int32_t ssi_status; /* exit status or signal (SIGCHLD) */
147 int32_t ssi_int; /* unused */
148 uint64_t ssi_ptr; /* unused */
149 uint64_t ssi_utime; /* user CPU time consumed (SIGCHLD) */
150 uint64_t ssi_stime; /* system CPU time consumed (SIGCHLD) */
151 uint64_t ssi_addr; /* address that generated signal */
152 uint8_t ssi_pad[48]; /* pad size to 128 bytes */
153 } signalfd_siginfo_t;
156 File descriptor duplication during fork presents a challenge to the
158 facility since signal data and events are dependent on the process from which
160 Its use with caching event systems such as
165 can result in undefined behavior if signalfd and polling descriptors are used
166 together after being shared across a fork.
167 Such restrictions do not apply if the child only calls
171 Upon successful completion, a file descriptor associated with the instance
173 Otherwise, -1 is returned and errno is set to indicate the error.
176 is not -1 and there is no error, the value of
181 .Fn signalfd function
187 descriptor is invalid.
195 descriptor is not a signalfd descriptor or the
201 file descriptors open in the calling process.
203 Unable to allocate state for the file descriptor.