aio_read.2 (2010 09)
a
aio_read(2) aio_read(2)
Once the read request has been enqueued by
aio_read(), the following errors, in addition to all of the
errors normally reported by the
read() function, may be reported asynchronously by a subsequent call
to aio_error() or aio_return() referencing its aiocb.
[EBADF] The
aiocbp->aio_fildes
was not a valid file descriptor open for reading.
[EINVAL] The value of
aiocbp->aio_reqprio
is not valid.
[EINVAL] The value of
aiocbp->aio_nbytes
is invalid.
[EINVAL] The file offset implied by
aiocbp->aio_offset
or
aiocbp->aio_offset+aiocbp->aio_nbytes are not valid for the file at the
time the request is processed.
[ECANCELED]
The read operation was canceled due to a subsequent call to
aio_cancel().
EXAMPLES
The following code sequence and call to
aio_read() starts an asynchronous read operation.
#include <fcntl.h>
#include <errno.h>
#include <aio.h>
char buf[4096];
ssize_t retval; ssize_t nbytes;
struct aiocb myaiocb;
bzero( &myaiocb, sizeof (struct aiocb));
myaiocb.aio_fildes = open( "/dev/null", O_RDONLY);
myaiocb.aio_offset = 0;
myaiocb.aio_buf = (void *) buf;
myaiocb.aio_nbytes = sizeof (buf);
myaiocb.aio_sigevent.sigev_notify = SIGEV_NONE;
retval = aio_read( &myaiocb );
if (retval) perror("aio_read:");
/* continue processing */
...
/* wait for completion */
while ( (retval = aio_error( &myaiocb) ) == EINPROGRESS) ;
/* free the aiocb */
nbytes = aio_return( &myaiocb);
SEE ALSO
aio_cancel(2), aio_error(2), aio_fsync(2), aio_return(2), aio_suspend(2), aio_write(2), lio_listio(2), read(2),
aio(5).
STANDARDS CONFORMANCE
aio_read(): POSIX Realtime Extensions, IEEE Std 1003.1b
2 Hewlett-Packard Company − 2 − HP-UX 11i Version 3: September 2010