~ubuntu-branches/ubuntu/saucy/manpages/saucy

« back to all changes in this revision

Viewing changes to man2/eventfd.2

  • Committer: Bazaar Package Importer
  • Author(s): Loïc Minier
  • Date: 2010-11-11 16:51:09 UTC
  • mfrom: (1.1.44 upstream) (2.2.7 sid)
  • Revision ID: james.westby@ubuntu.com-20101111165109-3yiyen1axa1ju3s0
Tags: 3.26-1ubuntu1
* Merge from Debian unstable; remaining changes:
  - ptrace.2, prctl.2: document Ubuntu-specific PTRACE_ATTACH,
    PR_SET_PTRACER behavior.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
.\"
19
19
.\" 2008-10-10, mtk: describe eventfd2(), and EFD_NONBLOCK and EFD_CLOEXEC
20
20
.\"
21
 
.TH EVENTFD 2 2009-01-26 Linux "Linux Programmer's Manual"
 
21
.TH EVENTFD 2 2010-08-30 Linux "Linux Programmer's Manual"
22
22
.SH NAME
23
23
eventfd \- create a file descriptor for event notification
24
24
.SH SYNOPSIS
36
36
This counter is initialized with the value specified in the argument
37
37
.IR initval .
38
38
 
39
 
Starting with Linux 2.6.27, the following values may be bitwise ORed in
 
39
The following values may be bitwise ORed in
40
40
.IR flags
41
41
to change the behaviour of
42
42
.BR eventfd ():
43
 
.TP 14
44
 
.B EFD_NONBLOCK
45
 
Set the
46
 
.BR O_NONBLOCK
47
 
file status flag on the new open file description.
48
 
Using this flag saves extra calls to
49
 
.BR fcntl (2)
50
 
to achieve the same result.
51
43
.TP
52
 
.B EFD_CLOEXEC
 
44
.BR EFD_CLOEXEC " (since Linux 2.6.27)"
53
45
Set the close-on-exec
54
46
.RB ( FD_CLOEXEC )
55
47
flag on the new file descriptor.
58
50
flag in
59
51
.BR open (2)
60
52
for reasons why this may be useful.
 
53
.TP
 
54
.BR EFD_NONBLOCK " (since Linux 2.6.27)"
 
55
Set the
 
56
.BR O_NONBLOCK
 
57
file status flag on the new open file description.
 
58
Using this flag saves extra calls to
 
59
.BR fcntl (2)
 
60
to achieve the same result.
 
61
.TP
 
62
.BR EFD_SEMAPHORE " (since Linux 2.6.30)"
 
63
Provide semaphore-like semantics for reads from the new file descriptor.
 
64
See below.
61
65
.PP
62
66
In Linux up to version 2.6.26, the
63
67
.I flags
70
74
The following operations can be performed on the file descriptor:
71
75
.TP
72
76
.BR read (2)
73
 
If the eventfd counter has a nonzero value, then a
 
77
Each successful
 
78
.BR read (2)
 
79
returns an 8-byte integer.
 
80
A
 
81
.BR read (2)
 
82
will fail with the error
 
83
.B EINVAL
 
84
if the size of the supplied buffer is less than 8 bytes.
 
85
.IP
 
86
The value returned by
 
87
.BR read (2)
 
88
is in host byte order,
 
89
i.e., the native byte order for integers on the host machine.
 
90
.IP
 
91
The semantics of
 
92
.BR read (2)
 
93
depend on whether the eventfd counter currently has a nonzero value
 
94
and whether the
 
95
.BR EFD_SEMAPHORE
 
96
flag was specified when creating the eventfd file descriptor:
 
97
.RS
 
98
.IP * 3
 
99
If
 
100
.BR EFD_SEMAPHORE
 
101
was not specified and the eventfd counter has a nonzero value, then a
74
102
.BR read (2)
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.)
79
 
.IP
80
 
If the counter is zero at the time of the
 
105
.IP *
 
106
If
 
107
.BR EFD_SEMAPHORE
 
108
was specified and the eventfd counter has a nonzero value, then a
 
109
.BR read (2)
 
110
returns 8 bytes containing the value 1,
 
111
and the counter's value is decremented by 1.
 
112
.IP *
 
113
If the eventfd counter is zero at the time of the call to
81
114
.BR read (2),
82
 
then the call either blocks until the counter becomes nonzero,
 
115
then the call either blocks until the counter becomes nonzero
 
116
(at which time, the
 
117
.BR read (2)
 
118
proceeds as described above)
83
119
or fails with the error
84
120
.B EAGAIN
85
121
if the file descriptor has been made nonblocking.
86
 
.IP
87
 
A
88
 
.BR read (2)
89
 
will fail with the error
90
 
.B EINVAL
91
 
if the size of the supplied buffer is less than 8 bytes.
 
122
.RE
92
123
.TP
93
124
.BR write (2)
94
125
A
186
217
File descriptors created by
187
218
.BR eventfd ()
188
219
are preserved across
189
 
.BR execve (2).
 
220
.BR execve (2),
 
221
unless the close-on-exec flag has been set.
190
222
.SH "RETURN VALUE"
191
223
On success,
192
224
.BR eventfd ()
197
229
.SH ERRORS
198
230
.TP
199
231
.B EINVAL
200
 
.I flags
201
 
is invalid;
202
 
or, in Linux 2.6.26 or earlier,
203
 
.I flags
204
 
is nonzero.
 
232
An unsupported value was specified in
 
233
.IR flags .
205
234
.TP
206
235
.B EMFILE
207
236
The per-process limit on open file descriptors has been reached.
397
426
.BR epoll (7),
398
427
.BR sem_overview (7)
399
428
.SH COLOPHON
400
 
This page is part of release 3.25 of the Linux
 
429
This page is part of release 3.26 of the Linux
401
430
.I man-pages
402
431
project.
403
432
A description of the project,