- /* get fd settings */
- if ((iof = fcntl(fd, F_GETFL, 0)) != -1) {
- /* set fd non blocking */
- fcntl(fd, F_SETFL, iof | O_NONBLOCK);
- /* read input */
- if (read(fd, &ev, sizeof(ev)) < 0) {
- if (num_warnings % 10000 == 0)
- /* should not happen cause select called before */
- fprintf(stderr, "Failed to read event from Jog Shuttle FILE DESCRIPTOR (repeated %d times)\n", num_warnings + 1);
- num_warnings++;
+ /* read input */
+ readResult = read(fd, &ev, sizeof(ev));
+ if (readResult < 0) {
+ if (num_warnings % 10000 == 0) {
+ /* if device is not available anymore - dead or disconnected */
+ fprintf(stderr, "Failed to read event from Jog Shuttle FILE DESCRIPTOR (repeated %d times)\n", num_warnings + 1);