aio_cancel(3)

NAME
aio_cancel - Cancel asynchronous I/O requests

SYNOPSYS
#include <errno.h>

#include <aio.h>

int aio_cancel (int fildes ,structaiocb*aiocbp )

DESCRIPTION
When one or more requests are asynchronously processed, it might be useful in some situations to cancel a selected operation, e.g., if it becomes obvious that the written data is no longer accurate and would have to be overwritten soon. As an example, assume an application, which writes data in files in a situation where new incoming data would have to be written in a file which will be updated by an enqueued request. The POSIX AIO implementation provides such a function, but this function is not capable of forcing the cancellation of the request. It is up to the implementation to decide whether it is possible to cancel the operation or not. Therefore using this function is merely a hint. The libaio implementation does not implement the cancel operation in the POSIX libraries .

The aio_cancel function can be used to cancel one or more outstanding requests. If the aiocbp parameter is NULL , the function tries to cancel all of the outstanding requests which would process the file descriptor fildes (i.e., whose aio_fildes member is fildes ). If aiocbpisnot NULL , aio_cancel attempts to cancel the specific request pointed to by aiocbp. For requests which were successfully canceled, the normal notification about the termination of the request should take place. I.e., depending on the struct sigevent object which controls this, nothing happens, a signal is sent or a thread is started. If the request cannot be canceled, it terminates the usual way after performing the operation. After a request is successfully canceled, a call to aio_error with a reference to this request as the parameter will return ECANCELED and a call to aio_return will return -1. If the request wasn't canceled and is still running the error status is still EINPROGRESS. When the sources are compiled with _FILE_OFFSET_BITS == 64 , this function is in fact aio_cancel64 since the LFS interface transparently replaces the normal implementation.

RETURN VALUES

AIO_CANCELED
    If there were requests which haven't terminated and which were successfully canceled.

AIO_NOTCANCELED
    If there is one or more requests left which couldn't be canceled, aio_error must be used to find out which of the, perhaps multiple, requests (in aiocbp is NULL ) weren't successfully canceled.

AIO_ALLDONE
    If all requests already terminated at the time aio_cancel is called the return value is

ERRORS
If an error occurred during the execution of aio_cancel the function returns -1 and sets errno to one of the following values.

EBADF
    The file descriptor fildes is not valid.

ENOSYS
    aio_cancel is not implemented.

SEE ALSO
aio(3), aio_cancel64(3), aio_error(3), aio_error64(3), aio_fsync(3), aio_fsync64(3), aio_init(3), aio_read(3), aio_read64(3), aio_return(3), aio_return64(3), aio_suspend(3), aio_suspend64(3), aio_write(3), aio_write64(3), errno(3),