diff options
-rw-r--r-- | coreutils/head.c | 4 | ||||
-rw-r--r-- | head.c | 4 |
2 files changed, 2 insertions, 6 deletions
diff --git a/coreutils/head.c b/coreutils/head.c index 0c8ef3d59..688c250b1 100644 --- a/coreutils/head.c +++ b/coreutils/head.c @@ -22,7 +22,6 @@ * */ -#include <errno.h> #include <stdio.h> #include <getopt.h> #include <stdlib.h> @@ -82,10 +81,9 @@ int head_main(int argc, char **argv) printf("==> %s <==\n", argv[optind]); } head(len, fp); - if (errno) { + if (ferror(fp)) { perror_msg("%s", argv[optind]); status = EXIT_FAILURE; - errno = 0; } if (optind < argc - 1) putchar('\n'); @@ -22,7 +22,6 @@ * */ -#include <errno.h> #include <stdio.h> #include <getopt.h> #include <stdlib.h> @@ -82,10 +81,9 @@ int head_main(int argc, char **argv) printf("==> %s <==\n", argv[optind]); } head(len, fp); - if (errno) { + if (ferror(fp)) { perror_msg("%s", argv[optind]); status = EXIT_FAILURE; - errno = 0; } if (optind < argc - 1) putchar('\n'); |