The aiocbp is already in use for another asynchronous I/O operation.
Once the write operation request has been enqueued by aio_write(), all of the errors normally reported by the write() function and the following errors may be reported asynchronously and returned in a subsequent call to aio_error() or aio_return() referencing the aiocb supplied in the successful aio_write() call.
error code:
[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 processed.
[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.
EXAMPLE
The following code sequence and call to aio_write() starts an asynchronous write operation.
#include
#include
#include
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);
댓글 없음:
댓글 쓰기