From: Scott Worley Date: Thu, 26 Dec 2013 08:44:55 +0000 (-0800) Subject: Make EOF fatal X-Git-Tag: v1.0.0~10 X-Git-Url: http://git.scottworley.com/keystroke-timestamps/commitdiff_plain/d42889411bdc848ef3d027eb9e011271ad2ce29a Make EOF fatal --- diff --git a/keystroke-timestamps.c b/keystroke-timestamps.c index d25d572..e370b22 100644 --- a/keystroke-timestamps.c +++ b/keystroke-timestamps.c @@ -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) {