1IO_GETEVENTS(2) Linux Programmer's Manual IO_GETEVENTS(2)
2
3
4
6 io_getevents - read asynchronous I/O events from the completion queue
7
9 #include <linux/aio_abi.h> /* Defines needed types */
10 #include <linux/time.h> /* Defines 'struct timespec' */
11
12 int io_getevents(aio_context_t ctx_id, long min_nr, long nr,
13 struct io_event *events, struct timespec *timeout);
14
15 Note: There is no glibc wrapper for this system call; see NOTES.
16
18 Note: this page describes the raw Linux system call interface. The
19 wrapper function provided by libaio uses a different type for the
20 ctx_id argument. See NOTES.
21
22 The io_getevents() system call attempts to read at least min_nr events
23 and up to nr events from the completion queue of the AIO context speci‐
24 fied by ctx_id.
25
26 The timeout argument specifies the amount of time to wait for events,
27 and is specified as a relative timeout in a structure of the following
28 form:
29
30 struct timespec {
31 time_t tv_sec; /* seconds */
32 long tv_nsec; /* nanoseconds [0 .. 999999999] */
33 };
34
35 The specified time will be rounded up to the system clock granularity
36 and is guaranteed not to expire early.
37
38 Specifying timeout as NULL means block indefinitely until at least
39 min_nr events have been obtained.
40
42 On success, io_getevents() returns the number of events read. This may
43 be 0, or a value less than min_nr, if the timeout expired. It may also
44 be a nonzero value less than min_nr, if the call was interrupted by a
45 signal handler.
46
47 For the failure return, see NOTES.
48
50 EFAULT Either events or timeout is an invalid pointer.
51
52 EINTR Interrupted by a signal handler; see signal(7).
53
54 EINVAL ctx_id is invalid. min_nr is out of range or nr is out of
55 range.
56
57 ENOSYS io_getevents() is not implemented on this architecture.
58
60 The asynchronous I/O system calls first appeared in Linux 2.5.
61
63 io_getevents() is Linux-specific and should not be used in programs
64 that are intended to be portable.
65
67 Glibc does not provide a wrapper function for this system call. You
68 could invoke it using syscall(2). But instead, you probably want to
69 use the io_getevents() wrapper function provided by libaio.
70
71 Note that the libaio wrapper function uses a different type (io_con‐
72 text_t) for the ctx_id argument. Note also that the libaio wrapper
73 does not follow the usual C library conventions for indicating errors:
74 on error it returns a negated error number (the negative of one of the
75 values listed in ERRORS). If the system call is invoked via
76 syscall(2), then the return value follows the usual conventions for in‐
77 dicating an error: -1, with errno set to a (positive) value that indi‐
78 cates the error.
79
81 An invalid ctx_id may cause a segmentation fault instead of generating
82 the error EINVAL.
83
85 io_cancel(2), io_destroy(2), io_setup(2), io_submit(2), aio(7), time(7)
86
88 This page is part of release 5.10 of the Linux man-pages project. A
89 description of the project, information about reporting bugs, and the
90 latest version of this page, can be found at
91 https://www.kernel.org/doc/man-pages/.
92
93
94
95Linux 2020-12-21 IO_GETEVENTS(2)