diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2016-12-12 08:31:32 -0800 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2016-12-12 08:34:00 -0800 |
commit | ca66d6f9cc769c3cb6ff3293725b8742840b98fa (patch) | |
tree | 0d070ef3109c552a8e866ed8ac2b748d4fd4fc3f /src/grep.c | |
parent | a3721c43f96beb255c533118bfaba1ddf8d9a6be (diff) | |
download | grep-ca66d6f9cc769c3cb6ff3293725b8742840b98fa.tar.gz |
grep: work around proc lseek glitch
Problem reported by Andreas Schwab (Bug#25180).
* NEWS: Document this.
* src/grep.c (finalize_input): Ignore EINVAL lseek failures.
* tests/Makefile.am (TESTS): Add proc.
* tests/proc: New file.
Diffstat (limited to 'src/grep.c')
-rw-r--r-- | src/grep.c | 9 |
1 files changed, 6 insertions, 3 deletions
@@ -1760,9 +1760,12 @@ finalize_input (int fd, struct stat const *st, bool ineof) { if (fd == STDIN_FILENO && (outleft - ? (!ineof && (seek_failed - ? ! drain_input (fd, st) - : lseek (fd, 0, SEEK_END) < 0)) + ? (!ineof + && (seek_failed + || (lseek (fd, 0, SEEK_END) < 0 + /* Linux proc file system has EINVAL (Bug#25180). */ + && errno != EINVAL)) + && ! drain_input (fd, st)) : (bufoffset != after_last_match && !seek_failed && lseek (fd, after_last_match, SEEK_SET) < 0))) suppressible_error (errno); |