aio_write(3aio) aio_write(3aio)
NAME
aio_write - asynchronous write
SYNOPSIS
cc [options] -D_REENTRANT file -lthread
#include <aio.h>
int aio_write(struct aiocb *aiocbp);
DESCRIPTION
aio_write supports an asynchronous write capability.
aio_write allows you to write aio_nbytes to the file
associated with file descriptor aio_fildes from the buffer
pointed to by aio_buf.
aiocbp points to an aiocb structure which contains other input
parameters as well as completion status members.
If you do not wish to be notified of completion, you should
set aio_sigevent.sigev_notify to SIGEV_NONE in the
asynchronous I/O control block. If you require notification,
you must set the aio_sigevent.sigev_notify to SIGEV_CALLBACK,
aio_sigevent.sigev_func to the address of the function to be
called, and aio_sigevent.sigev_value to the argument to be
passed to the function. You may also want the
aio_sigevent.sigev_value to be the address of the asynchronous
I/O control block that was used to initiate the I/O request.
[See aiocb(5)].
If the control block pointed to by aiocbp or the buffer
pointed to by aio_buf becomes an invalid address prior to
asynchronous I/O completion, then the behavior is undefined.
The call to aio_write returns 0 when the write request has
been initiated or queued to the file or device. If an error
condition is encountered during queuing, the call returns -1
without having initiated or queued the request.
Return Values
The call to aio_write returns 0 when the write request has
been initiated or queued to the file or device. If an error
condition is encountered during queuing, the call returns -1
without having initiated or queued the request. When the call
to aio_write has completed successfully, aio_write returns 0
and the structure member aio_errno is set to EINPROGRESS.
When the call to aio_write fails, After the write operation
has successfully completed, the aio_errno structure member is
Copyright 1994 Novell, Inc. Page 1
aio_write(3aio) aio_write(3aio)
set to 0. The aio_return function can be used to access the
return value of the underlying write call.
Errors
There are two types of errors that are associated with an
asynchronous I/O request. The first occurs during the
validity checking of the I/O request submitted by the
aio_write routine. This error is returned to the caller of
aio_write. The other occurs during the processing of the
actual write operation. The write operation may fail for any
of the reasons that a normal write may fail. If the call to
aio_write successfully queues the I/O operation but the
operation is subsequently canceled or encounters an error, the
aio_error function will return one of the values normally
returned by the write system call or one of the errors listed
below. The time at which the error occurs is implementation-
dependent; for example, an invalid file descriptor may not be
determined at the time of the call to aio_write which could
successfully complete. However, aio_error will return EBADF
to indicate the error.
The notification specified for a request will only be
performed if that request was successfully queued.
Under the following conditions, aio_write fails and sets errno
or the aio_errno structure member to:
EAGAIN The requested asynchronous I/O operation was not queued
because of system resource limitations. The first
request to encounter a resource limitation and all
subsequent requests will be marked so that aio_error
returns EAGAIN.
EFAULT aiocbp or the aio_buf member points outside the
allocated address space.
ECANCELED
The requested I/O was canceled before the I/O completed
due to aio_cancel.
EINVAL On SVR4.2, the request does not have the AIO_RAW flag
bit set in aio_flags.
REFERENCES
aio_cancel(3aio), aiocb(5), aio_read(3aio), aio_suspend(3aio),
write(2)
Copyright 1994 Novell, Inc. Page 2
aio_write(3aio) aio_write(3aio)
NOTICES
When developing applications for both SVR4.2 and future
versions, the AIO_RAW flag should be set in aio_flags to
insure that performance is maintained.
Copyright 1994 Novell, Inc. Page 3