HP-UX Reference (11i v1 00/12) - 2 System Calls (vol 5)

__________________________________________________________________________________________________________________________________________________________________________________________________
__________________________________________________________________________________________________________________________________________________________________________________________________
STANDARD Printed by: Nora Chuang [nchuang] STANDARD
/build/1111/BRICK/man2/!!!intro.2
________________________________________________________________
___ ___
a
aio_read(2) aio_read(2)
[EEXIST] The aiocbp is already in use for another asynchronous I/O operation.
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 subsequentcall to aio_cancel() .
EXAMPLE
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
Section 216 2 HP-UX Release 11i: December 2000
___
___