linux文件读写 文件锁、select、poll【转】
转载
#define MAX_BUFFER_SIZE 1024
#define IO_IN_FILES 3
#define TIME_DELAY 60000
int main() {
struct pollfd fds[IO_IN_FILES];
char buff[MAX_BUFFER_SIZE];
int i,res,real_read;
fds[0].fd=0;
if((fds[1].fd=open("in1",O_RDONLY|O_NONBLOCK))<0) {
printf("Open in1 error!\n");
return 1;
}
if((fds[2].fd=open("in2",O_RDONLY|O_NONBLOCK))<0) {
printf("Open in2 error!\n");
return 1;
}
for(i=0;i