AIO_READ(3P)
β¨ aio_read(3P) β¨
okay so bestie, welcome to the POSIX Programmer's Manual page for aio_read. This is the POSIX spec version, not the Linux one, so heads up. Sit down, hydrate, and let's get into it π«Ά
πΈ PROLOG πΈ
This manual page is part of the POSIX Programmer's Manual. The Linux implementation of this interface may differ β so like, consult the corresponding Linux manual page for details of Linux behavior β or honestly the interface may not even be implemented on Linux. Vibe check accordingly. π
π NAME π
aio_read β asynchronous read from a file
Asynchronous as in: you ask for the read, you don't sit there waiting for it like a loser. Main character energy only. π
π SYNOPSIS π
#include <aio.h>
int aio_read(struct aiocb *aiocbp);
π¦ DESCRIPTION π¦
So aio_read() shall read aiocbp->aio_nbytes from the file associated with aiocbp->aio_fildes into the buffer pointed to by aiocbp->aio_buf. π
And the iconic part: the function call shall return when the read request has been initiated or queued to the file or device β even when the data cannot be delivered immediately. Not me returning before the data even shows up π that's literally the whole point.
If prioritized I/O is supported for this file, then the asynchronous operation shall be submitted at a priority equal to a base scheduling priority minus aiocbp->aio_reqprio. And here's the fork in the road:
- If Thread Execution Scheduling is not supported, then the base scheduling priority is that of the calling process.
- Otherwise, the base scheduling priority is that of the calling thread.
The aiocbp value may be used as an argument to aio_error() and aio_return() in order to determine the error status and return status, respectively, of the asynchronous operation while it is proceeding. Like, checking in on your request mid-flight. π΅οΈββοΈ
If an error condition is encountered during queuing, the function call shall return without having initiated or queued the request. No half-queued nonsense, periodt.
The requested operation takes place at the absolute position in the file as given by aio_offset, as if lseek() were called immediately prior to the operation with an offset equal to aio_offset and a whence equal to SEEK_SET. And after a successful call to enqueue an asynchronous I/O operation, the value of the file offset for the file is unspecified. π Yeah. Unspecified. Don't count on it.
The aio_sigevent member specifies the notification which occurs when the request is completed. π¬
The aiocbp->aio_lio_opcode field shall be ignored by aio_read(). It's giving "not my problem, not my field." π
The aiocbp argument points to an aiocb structure. Now listen up, because this one is a real warning:
If the buffer pointed to byaiocbp->aio_bufor the control block pointed to byaiocbpbecomes an illegal address prior to asynchronous I/O completion, then the behavior is undefined. π
Also: simultaneous asynchronous operations using the same aiocbp produce undefined results. Share the struct, suffer the consequences, no cap.
If synchronized I/O is enabled on the file associated with aiocbp->aio_fildes, the behavior of this function shall be according to the definitions of synchronized I/O data integrity completion and synchronized I/O file integrity completion.
For any system action that changes the process memory space while an asynchronous I/O is outstanding to the address range being changed, the result of that action is undefined. π₯
And for regular files: no data transfer shall occur past the offset maximum established in the open file description associated with aiocbp->aio_fildes.
π RETURN VALUE π
- The
aio_read()function shall return the value zero if the I/O operation is successfully queued. β¨ - Otherwise, the function shall return the value
-1and seterrnoto indicate the error. π
π₯ ERRORS π₯
The aio_read() function shall fail if:
EAGAINβ The requested asynchronous I/O operation was not queued due to system resource limitations. (The system said "not today bestie." π)
okay now here's the part where it gets ~nuanced~ β each of the following conditions may be detected synchronously at the time of the call to aio_read(), or asynchronously.
- If any of the conditions below are detected synchronously, the
aio_read()function shall return-1and seterrnoto the corresponding value. - If any of the conditions below are detected asynchronously, the return status of the asynchronous operation is set to
-1, and the error status of the asynchronous operation is set to the corresponding value.
The conditions:
EBADFβ Theaiocbp->aio_fildesargument is not a valid file descriptor open for reading.EINVALβ The file offset value implied byaiocbp->aio_offsetwould be invalid,aiocbp->aio_reqpriois not a valid value, oraiocbp->aio_nbytesis an invalid value.
In the case that the aio_read() successfully queues the I/O operation but the operation is subsequently canceled or encounters an error, the return status of the asynchronous operation is one of the values normally returned by the read() function call. In addition, the error status of the asynchronous operation is set to one of the error statuses normally set by the read() function call, or one of the following values:
EBADFβ Theaiocbp->aio_fildesargument is not a valid file descriptor open for reading.ECANCELEDβ The requested I/O was canceled before the I/O completed due to an explicitaio_cancel()request. (You did this. You canceled it. π« )EINVALβ The file offset value implied byaiocbp->aio_offsetwould be invalid.
The following condition may be detected synchronously or asynchronously:
EOVERFLOWβ The file is a regular file,aiobcp->aio_nbytesis greater than 0, and the starting offset inaiobcp->aio_offsetis before the end-of-file and is at or beyond the offset maximum in the open file description associated withaiocbp->aio_fildes.
The following sections are informative. (So like, lore, not law. π)
π EXAMPLES π
None.
πΈ APPLICATION USAGE πΈ
None.
π RATIONALE π
None.
β FUTURE DIRECTIONS β
None.
π¦ SEE ALSO π¦
aio_cancel(), aio_error(), lio_listio(), aio_return(), aio_write(), close(), exec, exit(), fork(), lseek(), read()
The Base Definitions volume of POSIX.1β2017, <aio.h>
π COPYRIGHT π
Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1-2017, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html .
Any typographical or formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man page format. To report such errors, see https://www.kernel.org/doc/man-pages/reporting_bugs.html .
okay that's the whole page bestie, you ate it, no crumbs π
This was IEEE/The Open Group, 2017, page AIO_READ(3P) β signing off, mwah πβ¨ππ¦πΈπ«Ά
π¦ where this page comes from
- alpine 3.22: man-pages-posix 2017a-r0 Β· custom
- alpine 3.23: man-pages-posix 2017a-r0 Β· custom
- alpine 3.24: man-pages-posix 2017a-r0 Β· custom
- arch rolling: man-pages 6.19-1
- arch rolling: man-pages 6.20-1 Β· BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
- nixpkgs unstable: man-pages-posix 2017a
- opensuse-leap 16.0: man-pages-posix 2017a-160000.4.1 Β· SUSE-IEEE
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms