#include #include #include #include #include int main(void) { FILE *fp1,*fp2; fd_set fdst; char buffer[100]; int i; if((fp1 = fopen("test1.txt","r")) == NULL){ return 0; } if((fp2 = fopen("test2.txt","r")) == NULL){ return 0; } /* Daemon-specific initialization goes here */ /* The Big Loop */ while (1) { /* Do some task here ... */ FD_ZERO(&fdst); FD_SET(fileno(fp1),&fdst); FD_SET(fileno(fp2),&fdst); select(fileno(fp2)+1,&fdst,NULL,NULL,NULL); if(FD_ISSET(fileno(fp1),&fdst)){ while(fgets(buffer,100,fp1) != NULL){ puts(buffer); } } if(FD_ISSET(fileno(fp2),&fdst)){ while(fgets(buffer,100,fp2) != NULL){ puts(buffer); } } //fprintf(stderr,"%d\n",i++); } exit(EXIT_SUCCESS); }