다음 코드 : (-lrt로 컴파일 우분투 9.10) 리눅스에aio_read X
#include <fcntl.h>
#include <unistd.h>
#include <stdio.h>
#include <aio.h>
#include <errno.h>
int main (int argc, char const *argv[])
{
char name[] = "abc";
int fdes;
if ((fdes = open(name, O_RDWR | O_CREAT, 0600)) < 0)
printf("%d, create file", errno);
int buffer[] = {0, 1, 2, 3, 4, 5};
if (write(fdes, &buffer, sizeof(buffer)) == 0){
printf("writerr\n");
}
struct aiocb aio;
int n = 2;
while (n--){
aio.aio_reqprio = 0;
aio.aio_fildes = fdes;
aio.aio_offset = sizeof(int);
aio.aio_sigevent.sigev_notify = SIGEV_NONE;
int buffer2;
aio.aio_buf = &buffer2;
aio.aio_nbytes = sizeof(buffer2);
if (aio_read(&aio) != 0){
printf("%d, readerr\n", errno);
}else{
const struct aiocb *aio_l[] = {&aio};
if (aio_suspend(aio_l, 1, 0) != 0){
printf("%d, suspenderr\n", errno);
}else{
printf("%d\n", *(int *)aio.aio_buf);
}
}
}
return 0;
}
작품 좋은,
1
1
그러나 OS X에서 실패 인쇄 (10.6
1
35, readerr
는이 OS X에 대한 몇 가지 라이브러리 오류 때문이라고이 가능, 아니면 솜을하고있는 중이 야 : 0.6 및 10.6.5, 나는)이 기계에 그것을 테스트했습니다 잘못 됐어?
단지 '35EAGAIN'이며, "시스템 자원 제한으로 인해 요청이 대기열에 없습니다 .." –