- if (status == 0)
- printf("Poll timed out\n");
- else {
- printf("Poll returned a descriptor: ");
- if (fd.revents & POLLIN)
- printf("readable, ");
- else
- printf("not readable, ");
- if (fd.revents & POLLERR)
- printf("exceptional condition, ");
- else
- printf("no exceptional condition, ");
- if (fd.revents & POLLHUP)
- printf("disconnect, ");
- else
- printf("no disconnect, ");
- if (fd.revents & POLLNVAL)
- printf("invalid\n");
- else
- printf("not invalid\n");
+ if (selectable_fd == -1) {
+ if (status != 0)
+ printf("Poll returned a descriptor\n");
+ } else {
+ if (status == 0)
+ printf("Poll timed out\n");
+ else {
+ printf("Poll returned a descriptor: ");
+ if (fd.revents & POLLIN)
+ printf("readable, ");
+ else
+ printf("not readable, ");
+ if (fd.revents & POLLERR)
+ printf("exceptional condition, ");
+ else
+ printf("no exceptional condition, ");
+ if (fd.revents & POLLHUP)
+ printf("disconnect, ");
+ else
+ printf("no disconnect, ");
+ if (fd.revents & POLLNVAL)
+ printf("invalid\n");
+ else
+ printf("not invalid\n");
+ }