aio_cancel(2)

aio_cancel2

Cancel an outstanding asynchronous i/o operation (realtime)

Usage

#include <aio.h>

int

aio_cancel(int fildes, struct aiocb *iocb);

Library

Standard C Library (libc, -lc)

Overview

The aio_cancel() system call cancels the outstanding asynchronous I/O request for the file descriptor specified in fildes. If iocb is specified, only that specific asynchronous I/O request is cancelled.

Normal asynchronous notification occurs for cancelled requests. Requests complete with an error result of ECANCELED.

Restrictions

The aio_cancel() system call does not cancel asynchronous I/O requests for raw disk devices. The aio_cancel() system call will always return AIO_NOTCANCELED for file descriptors associated with raw disk devices.

Return values

The aio_cancel() system call returns -1 to indicate an error, or one of the following:

[AIO_CANCELED]

All outstanding requests meeting the criteria specified were cancelled.

[AIO_NOTCANCELED]

Some requests were not cancelled, status for the requests should be checked with aio_error(2).

[AIO_ALLDONE]

All of the requests meeting the criteria have finished.

Errors

An error return from aio_cancel() indicates:

[EBADF]

The fildes argument is an invalid file descriptor.

Releases

74 releases since FreeBSD 3.3-RELEASE; the text changed 40 times.

  1. 3.3–3.4
  2. 3.5–3.5.1
  3. 4.0
  4. 4.1
  5. 4.1.1–4.2
  6. 4.3–4.4
  7. 4.5–4.11
  8. 5.0
  9. 5.1–6.3
  10. 6.4
  11. 7.0
  12. 7.1
  13. 7.2
  14. 7.3
  15. 7.4
  16. 8.0
  17. 8.1
  18. 8.2
  19. 8.3
  20. 8.4
  21. 9.0
  22. 9.1
  23. 9.2
  24. 9.3
  25. 10.0
  26. 10.1
  27. 10.2
  28. 10.3
  29. 10.4
  30. 11.0
  31. 11.1
  32. 11.2
  33. 11.3
  34. 11.4
  35. 12.0
  36. 12.1
  37. 12.2
  38. 12.3
  39. 12.4
  40. 13.0–13.2
  41. 13.3–16.0

Standards

The aio_cancel() system call is expected to conform to the IEEE Std 1003.1 (“POSIX.1”) standard.

History

The aio_cancel() system call first appeared in FreeBSD 3.0. The first functional implementation of aio_cancel() appeared in FreeBSD 4.0.

Authors

This manual page was originally written by Wes Peters ⟨[email protected]⟩. Christopher M Sedore ⟨[email protected]⟩ updated it when aio_cancel() was implemented for FreeBSD 4.0.

From base 16.0-CURRENT-20261027-61c70dc16a79 in FreeBSD 16.0-CURRENT (2026-10-27). Parsed by carta from the page's mdoc source.