]> git.scottworley.com Git - keystroke-timestamps/blobdiff - keystroke-timestamps.c
Make EOF fatal
[keystroke-timestamps] / 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 (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) {