]> git.scottworley.com Git - keystroke-timestamps/commitdiff
Make EOF fatal
authorScott Worley <scottworley@scottworley.com>
Thu, 26 Dec 2013 08:44:55 +0000 (00:44 -0800)
committerScott Worley <scottworley@scottworley.com>
Thu, 26 Dec 2013 08:44:55 +0000 (00:44 -0800)
keystroke-timestamps.c

index d25d57281b3c7fe98ba50d72c9470c164599b2a6..e370b22dba4b06a395124341e62684d1f15e64f5 100644 (file)
@@ -43,8 +43,12 @@ int main (int argc, char **argv)
     if (select(fd+1, &ready_inputs, NULL, NULL, NULL) != 1) {
       err(EX_IOERR, "select");
     }
     if (select(fd+1, &ready_inputs, NULL, NULL, NULL) != 1) {
       err(EX_IOERR, "select");
     }
-    if (read(fd, &i, sizeof(i)) != sizeof(i)) {
-      break;
+    int read_return = read(fd, &i, sizeof(i));
+    if (read_return == -1) {
+      err(EX_IOERR, "read");
+    }
+    if (read_return != sizeof(i)) {
+      errx(EX_IOERR, "Unexpected EOF");
     }
     if (i.type == 1 && i.value == 1) {
       if (print_usec) {
     }
     if (i.type == 1 && i.value == 1) {
       if (print_usec) {