2 // from https://github.com/imyjf/apue/blob/master/my_aio_read.c
3 // and I guess originally from APUE but it isn't in my second
4 // edition (and I didn't keep the first edition)
15 #define ERR_EXIT(msg) do { perror(msg); exit(1); } while(0)
20 struct aiocb my_aiocb
;
22 bzero((char*)&my_aiocb
, sizeof(struct aiocb
));
24 my_aiocb
.aio_buf
= buf
;
25 my_aiocb
.aio_fildes
= STDIN_FILENO
;
26 my_aiocb
.aio_nbytes
= 64;
27 my_aiocb
.aio_offset
= 0;
29 ret
= aio_read(&my_aiocb
);
34 while (aio_error(&my_aiocb
) == EINPROGRESS
) {
35 //write(STDOUT_FILENO, ".", 1);
39 ret
= aio_return(&my_aiocb
);
41 ERR_EXIT("aio_return");
45 printf("content: %s\n", buf
);