Operation Canceled
Production Risk
Expected when using operation cancellation; handle like a retry condition.
ECANCELED (errno 125) is returned when an asynchronous operation was explicitly canceled, either via aio_cancel() or io_cancel(). It indicates the operation was stopped before completion — not that it failed.
- 1aio_cancel() successfully canceled a pending AIO request
- 2io_cancel() canceled a Linux io_uring or libaio operation
- 3pthread_cancel() canceled a thread that was in a cancellation point
aio_cancel() cancels a pending read.
struct aiocb cb = { .aio_fildes = fd, ... };
aio_read(&cb);
// Cancel before it completes
aio_cancel(fd, &cb);
// aio_error(&cb) returns ECANCELEDexpected output
aio_error: Operation canceled (ECANCELED)
Fix
Check cancellation status and handle appropriately
WHEN When using AIO or io_uring with cancellation
int err = aio_error(&cb);
if (err == ECANCELED) {
// Operation was canceled — retry if needed
aio_read(&cb);
} else if (err == 0) {
// Completed — read result with aio_return()
ssize_t n = aio_return(&cb);
}Why this works
ECANCELED means the operation was intentionally stopped; retry or skip as the application logic requires.
✕ Treat ECANCELED as a permanent failure
The operation was canceled, not failed; it can be safely retried.
Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev