AIO_WRITE(3P)
β¨ AIO_WRITE(3P) β¨
okay bestie, welcome to the POSIX Programmer's Manual π this page is literally part of it. quick heads up tho β the Linux implementation of this interface may differ (so go consult the corresponding Linux manual page for the deets on Linux behavior), or honestly the interface may not be implemented on Linux at all. vibe check passed either way, let's go π¦
πΈ NAME πΈ
aio_write β asynchronous write to a file. yes, the asynchronous one. she does not wait. she queues and dips π
β¨ SYNOPSIS β¨
#include <aio.h>
int aio_write(struct aiocb *aiocbp);
π DESCRIPTION π
So the aio_write() function shall write aiocbp->aio_nbytes to the file associated with aiocbp->aio_fildes, from the buffer pointed to by aiocbp->aio_buf. And she shall return when the write request has been initiated or, at a minimum, queued to the file or device. queued and out, no waiting around π
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 if Thread Execution Scheduling is not supported, then that base scheduling priority is the one of the calling process; otherwise, the base scheduling priority is the one of the calling thread. iykyk π§
The aiocbp argument may be used as an argument to aio_error() and aio_return() to figure out the error status and return status, respectively, of the asynchronous operation while it's still proceeding. main character energy, checking in on your own op β¨
The aiocbp argument points to an aiocb structure. And here's the scary part, so listen up: if the buffer pointed to by aiocbp->aio_buf or the control block pointed to by aiocbp becomes an illegal address prior to asynchronous I/O completion, then the behavior is undefined. π not a drill.
If O_APPEND is not set for the file descriptor aio_fildes, then the requested operation shall take 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. If O_APPEND is set for the file descriptor, or if aio_fildes is associated with a device that is incapable of seeking, then write operations append to the file in the same order as the calls were made β except under circumstances described in Section 2.8.2, Asynchronous I/O. 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. we don't know her π
The aio_sigevent member specifies the notification which occurs when the request is completed. cute little ping when she's done π
The aiocbp->aio_lio_opcode field shall be ignored by aio_write(). ignored. not read. not considered. moving on π
Simultaneous asynchronous operations using the same aiocbp produce undefined results. so likeβ¦ don't do that bestie π
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. UNDEFINED. don't touch the memory while she's working π
For regular files, no data transfer shall occur past the offset maximum established in the open file description associated with aiocbp->aio_fildes. she knows her limits, periodt.
π₯ RETURN VALUE π₯
The aio_write() function shall return the value zero if the I/O operation is successfully queued; otherwise, the function shall return the value -1 and set errno to indicate the error. zero = slay, -1 = something went wrong, check errno π
π ERRORS π
The aio_write() function shall fail if:
EAGAINβ The requested asynchronous I/O operation was not queued due to system resource limitations. system said no room bestie π
Each of the following conditions may be detected synchronously at the time of the call to aio_write(), or asynchronously. If any of the conditions below are detected synchronously, the aio_write() function shall return -1 and set errno to the corresponding value. If any of the conditions below are detected asynchronously, the return status of the asynchronous operation shall be set to -1, and the error status of the asynchronous operation is set to the corresponding value. two paths, same drama β¨
EBADFβ Theaiocbp->aio_fildesargument is not a valid file descriptor open for writing.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_write() successfully queues the I/O operation, the return status of the asynchronous operation shall be one of the values normally returned by the write() function call. And if the operation is successfully queued but is subsequently canceled or encounters an error, the error status for the asynchronous operation contains one of the values normally set by the write() function call, or one of the following:
EBADFβ Theaiocbp->aio_fildesargument is not a valid file descriptor open for writing.EINVALβ The file offset value implied byaiocbp->aio_offsetwould be invalid.ECANCELEDβ The requested I/O was canceled before the I/O completed due to an explicitaio_cancel()request.
The following condition may be detected synchronously or asynchronously:
EFBIGβ The file is a regular file,aiobcp->aio_nbytesis greater than 0, and the starting offset inaiobcp->aio_offsetis at or beyond the offset maximum in the open file description associated withaiocbp->aio_fildes.
The following sections are informative. (translation: cute but not binding π«Ά)
π EXAMPLES π
None.
π APPLICATION USAGE π
None.
π¦ RATIONALE π¦
None.
β FUTURE DIRECTIONS β
None.
π SEE ALSO π
- Section 2.8.2, Asynchronous I/O
aio_cancel()aio_error()aio_read()aio_return()close()execexit()fork()lio_listio()lseek()write()
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 .
and that's the whole page bestie π β¨ this lil masterpiece was brought to you by IEEE/The Open Group, dated 2017 β thanks for coming to my TED talk, now go queue some async writes and stay hydrated π«ΆπΈ
π¦ 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