19
19
.\" 2008-10-10, mtk: describe eventfd2(), and EFD_NONBLOCK and EFD_CLOEXEC
21
.TH EVENTFD 2 2009-01-26 Linux "Linux Programmer's Manual"
21
.TH EVENTFD 2 2010-08-30 Linux "Linux Programmer's Manual"
23
23
eventfd \- create a file descriptor for event notification
36
36
This counter is initialized with the value specified in the argument
39
Starting with Linux 2.6.27, the following values may be bitwise ORed in
39
The following values may be bitwise ORed in
41
41
to change the behaviour of
47
file status flag on the new open file description.
48
Using this flag saves extra calls to
50
to achieve the same result.
44
.BR EFD_CLOEXEC " (since Linux 2.6.27)"
53
45
Set the close-on-exec
55
47
flag on the new file descriptor.
60
52
for reasons why this may be useful.
54
.BR EFD_NONBLOCK " (since Linux 2.6.27)"
57
file status flag on the new open file description.
58
Using this flag saves extra calls to
60
to achieve the same result.
62
.BR EFD_SEMAPHORE " (since Linux 2.6.30)"
63
Provide semaphore-like semantics for reads from the new file descriptor.
62
66
In Linux up to version 2.6.26, the
70
74
The following operations can be performed on the file descriptor:
73
If the eventfd counter has a nonzero value, then a
79
returns an 8-byte integer.
82
will fail with the error
84
if the size of the supplied buffer is less than 8 bytes.
88
is in host byte order,
89
i.e., the native byte order for integers on the host machine.
93
depend on whether the eventfd counter currently has a nonzero value
96
flag was specified when creating the eventfd file descriptor:
101
was not specified and the eventfd counter has a nonzero value, then a
75
103
returns 8 bytes containing that value,
76
104
and the counter's value is reset to zero.
77
(The returned value is in host byte order,
78
i.e., the native byte order for integers on the host machine.)
80
If the counter is zero at the time of the
108
was specified and the eventfd counter has a nonzero value, then a
110
returns 8 bytes containing the value 1,
111
and the counter's value is decremented by 1.
113
If the eventfd counter is zero at the time of the call to
82
then the call either blocks until the counter becomes nonzero,
115
then the call either blocks until the counter becomes nonzero
118
proceeds as described above)
83
119
or fails with the error
85
121
if the file descriptor has been made nonblocking.
89
will fail with the error
91
if the size of the supplied buffer is less than 8 bytes.