aio_write.2 (2010 09)

a
aio_write(2) aio_write(2)
[EBADF] The aiocbp->aio_fildes
was not a valid file descriptor open for writing.
[EINVAL] The
aiocb->aio_sigevent
is not a valid address in the process virtual address
space.
[EINVAL] The parameters of the indicated
sigevent in aiocb->aio_sigevent
are
invalid.
[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 pro-
cessed.
[ECANCELED]
The write operation was canceled due to a subsequent call to
aio_cancel()
referencing the same aiocb that was used to start the operation.
EXAMPLES
The following code sequence and call to
aio_write() starts an asynchronous write operation.
#include <fcntl.h>
#include <errno.h>
#include <aio.h>
char buf[4096];
int retval; ssize_t nbytes;
struct aiocb myaiocb;
bzero( &myaiocb, sizeof (struct aiocb));
bzero( &buf, sizeof (buf));
myaiocb.aio_fildes = open( "/dev/null", O_RDWR);
myaiocb.aio_offset = 0;
myaiocb.aio_buf = (void *) buf;
myaiocb.aio_nbytes = sizeof (buf);
myaiocb.aio_sigevent.sigev_notify = SIGEV_NONE;
retval = aio_write( &myaiocb );
if (retval) perror("aio_write:");
/* 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_read(2), aio_return(2), aio_suspend(2), lio_listio(2), write(2),
aio(5).
STANDARDS CONFORMANCE
aio_write(): POSIX Realtime Extensions, IEEE Std 1003.1b
2 Hewlett-Packard Company 2 HP-UX 11i Version 3: September 2010