---
name: "io_cancel"
section: "2"
platform: "linux"
package: "man-pages"
version: "6.19-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/io_cancel"
---

# io\_cancel(2)

cancel an outstanding asynchronous I/O operation

## NAME

io\_cancel - cancel an outstanding asynchronous I/O operation

## LIBRARY

Standard C library (*libc*, *-lc*)

## SYNOPSIS

```
#include <linux/aio_abi.h>    /* Definition of needed types */
#include <sys/syscall.h>      /* Definition of SYS_* constants */
#include <unistd.h>
```

**int syscall(SYS\_io\_cancel, aio\_context\_t** *ctx\_id***, struct iocb \****iocb***,**             **struct io\_event \****result***);**

## DESCRIPTION

*Note*: you probably want to use the [**io\_getevents**(3)](/io_getevents/3.md) wrapper function provided by *libaio*; see VERSIONS.

The **io\_cancel**() system call attempts to cancel an asynchronous I/O operation previously submitted with [**io\_submit**(2)](/io_submit/2.md). The *iocb* argument describes the operation to be canceled and the *ctx\_id* argument is the AIO context to which the operation was submitted. If the operation is successfully canceled, the event will be copied into the memory pointed to by *result* without being placed into the completion queue.

## RETURN VALUE

On success, **io\_cancel**() returns 0. On error, -1 is returned, and *errno* is set to indicate the error.

## ERRORS

- **EAGAIN**

  The *iocb* specified was not canceled.

- **EFAULT**

  One of the data structures points to invalid data.

- **EINVAL**

  The AIO context specified by *ctx\_id* is invalid.

- **ENOSYS**

  **io\_cancel**() is not implemented on this architecture.

## VERSIONS

*libaio* ⟨https://pagure.io/libaio⟩ provides a wrapper function with the same name, but different prototype and return value. You probably want to use that wrapper.

## STANDARDS

Linux.

## HISTORY

Linux 2.5.

## SEE ALSO

[**io\_destroy**(2)](/io_destroy/2.md), [**io\_getevents**(2)](/io_getevents/2.md), [**io\_setup**(2)](/io_setup/2.md), [**io\_submit**(2)](/io_submit/2.md), [**io\_cancel**(3)](/io_cancel/3.md), [**aio**(7)](/aio/7.md)
