From dff821d3e392d7ac39c44eb5ded43ea91ced92f2 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Fri, 14 Feb 2025 13:01:35 -0800 Subject: [PATCH] cat: omit unnecessary lseek MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit * src/cat.c (main): Don’t bother to try lseek on a fifo or socket, as it will fail. --- src/cat.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cat.c b/src/cat.c index 92773d354f..274f844a16 100644 --- a/src/cat.c +++ b/src/cat.c @@ -712,7 +712,8 @@ main (int argc, char **argv) output device. It's better to catch this error earlier rather than later. */ - if (! (S_TYPEISSHM (&stat_buf) || S_TYPEISTMO (&stat_buf)) + if (! (S_ISFIFO (stat_buf.st_mode) || S_ISSOCK (stat_buf.st_mode) + || S_TYPEISSHM (&stat_buf) || S_TYPEISTMO (&stat_buf)) && have_out_dev && stat_buf.st_dev == out_dev && stat_buf.st_ino == out_ino) { -- 2.47.3