#include <aio.h> #include <stdio.h> int main(int argc, char * argv[]) { if(argc != 2) { printf("Usage: %s {filename}\n", argv[0]); return -1; } struct aiocb cb; struct aiocb * cbs[1]; //Open the file specified on the command line FILE * file = fopen(argv[1], "r+"); //Set up the control block cb.aio_buf = malloc(11); cb.aio_fildes = fileno(file); cb.aio_nbytes = 10; cb.aio_offset = 0; //Perform the read aio_read(&cb); //Wait for it to complete cbs[0] = &cb; aio_suspend(cbs, 1, NULL); printf("AIO operation returned %d\n", aio_return(&cb)); return 0; }