1 .\" SPDX-License-Identifier: BSD-2-Clause
3 .\" Copyright (c) 2020 Greg V <greg@unrelenting.technology>
5 .\" Redistribution and use in source and binary forms, with or without
6 .\" modification, are permitted provided that the following conditions
8 .\" 1. Redistributions of source code must retain the above copyright
9 .\" notice, this list of conditions and the following disclaimer.
10 .\" 2. Redistributions in binary form must reproduce the above copyright
11 .\" notice, this list of conditions and the following disclaimer in the
12 .\" documentation and/or other materials provided with the distribution.
14 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 .Nd create a file descriptor for event notification
39 .Fn eventfd "unsigned int initval" "int flags"
41 .Fn eventfd_read "int fd" "eventfd_t *value"
43 .Fn eventfd_write "int fd" "eventfd_t value"
46 creates a special file descriptor with event counter or semaphore semantics,
47 designed for interprocess communication.
48 The returned file descriptor refers to a kernel object containing an
49 unsigned 64-bit integer counter, which is initialized with the value of the
55 argument may contain the result of
59 .Bl -tag -width "EFD_SEMAPHORE" -compact
61 set FD_CLOEXEC on the file descriptor
63 do not block on read/write operations
65 use semaphore semantics
68 File operations have the following semantics:
69 .Bl -tag -width EFD_SEMAPHORE
71 If the counter is zero, the call blocks until the counter becomes non-zero, unless
73 was set, in which case it would fail with
77 If the counter is non-zero:
82 is not set, the current value of the counter is returned,
83 and the value is reset to zero.
87 is set, the constant 1 is returned, and the value is decremented by 1.
90 The numeric value is encoded as 64-bit (8 bytes) in host byte order.
95 if there is less than 8 bytes available in the supplied buffer.
97 Adds the given value to the counter.
98 The maximum value that can be stored in the counter is the
99 maximum unsigned 64-bit integer value minus one (0xfffffffffffffffe).
101 If the resulting value exceeds the maximum, the call would block
102 until the value is reduced by
106 was set, in which case it would fail with
110 The numeric value is encoded as 64-bit (8 bytes) in host byte order.
115 if there is less than 8 bytes available in the supplied buffer,
116 or if the value 0xffffffffffffffff is given.
118 When receiving notifications via
124 the following semantics apply:
127 The file descriptor is readable when the counter is greater than zero.
129 The file descriptor is writable when the counter is less than the maximum value.
133 File descriptors created by
135 are passable to other processes via
137 and are preserved across
139 in both cases the descriptors refer to the same counter from both processes.
143 the created file descriptor will remain open across
155 are thin wrappers around
160 provided for compatibility with glibc.
164 returns a non-negative integer, termed a file descriptor.
165 It returns \-1 on failure, and sets
167 to indicate the error.
173 functions return 0 if the operation succeeded, -1 otherwise.
183 has unknown bits set.
185 The process has already reached its limit for open
188 The system file table is full.
190 No memory was available to create the kernel object.
202 system call is non-standard.
203 It is present in Linux.
207 system call first appeared in