Updated: April 19, 2023 |
Cancel an asynchronous I/O operation
#include <aio.h> int aio_cancel( int fd, struct aiocb * aiocbptr );
libc
Use the -l c option to qcc to link against this library. This library is usually included automatically.
The aio_cancel() function attempts to cancel one or more asynchronous I/O requests currently outstanding against a file descriptor.
Normal asynchronous notification occurs for asynchronous I/O operations that are successfully canceled. If there are requests that can't be canceled, then the normal asynchronous completion process takes place for those requests when they're completed.
The error status that's associated with requested operations that are successfully canceled is set to ECANCELED, and the return status is -1. The aio_cancel() function doesn't modify the aiocb structures for requested operations that aren't successfully canceled.
If aiocbptr isn't NULL, aio_cancel() ignores the fd argument and attempts to cancel the I/O operation specified by the aiocb control block. The operation isn't cancelled if it's already in progress.
Safety: | |
---|---|
Cancellation point | No |
Interrupt handler | No |
Signal handler | Yes |
Thread | Yes |
The first time you call an aio_* function, a thread pool is created, making your process multithreaded if it isn't already. Because of this, after a fork() the child can not use any of the aio_*() functions if the parent used any aio_*() functions before the fork(). The thread pool isn't destroyed until your process ends.