- FD_ZERO(&readSet);
- FD_SET(fd_out, &readSet);
-
- res = select(fd_out + 1, &readSet, NULL, NULL, &tv);
- if (res < 1) {
- printf("select failed\n");
- exit(-1);
+ while (1) {
+ FD_ZERO(&readSet);
+ FD_SET(fd_out, &readSet);
+
+ printf("Selecting...\n");
+ res = select(fd_out + 1, &readSet, NULL, NULL, NULL);
+ printf("Selected...\n");
+ if (res < 0) {
+ if (errno == EINTR || errno == EAGAIN) {
+ printf(".");
+ continue;
+ }
+ fprintf(stderr,"select failed errno=%d errstr=%s\n", errno, strerror(errno));
+ exit(-1);
+ }
+ break; /* we're done */