summaryrefslogtreecommitdiff
path: root/src/head.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/head.c')
-rw-r--r--src/head.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/head.c b/src/head.c
index d7e83b716..0d5e1b2c6 100644
--- a/src/head.c
+++ b/src/head.c
@@ -667,6 +667,14 @@ elide_tail_lines_seekable (const char *pretty_filename, int fd,
Don't bother testing for failure for such a small amount.
Any failure will be detected upon close. */
fwrite (buffer, 1, n + 1, stdout);
+
+ /* Set file pointer to the byte after what we've output. */
+ if (lseek (fd, pos + n + 1, SEEK_SET) < 0)
+ {
+ error (0, errno, "%s: failed to reset file pointer",
+ quote (pretty_filename));
+ return false;
+ }
return true;
}
}