]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
cat: omit unnecessary lseek
authorPaul Eggert <eggert@cs.ucla.edu>
Fri, 14 Feb 2025 21:01:35 +0000 (13:01 -0800)
committerPaul Eggert <eggert@cs.ucla.edu>
Fri, 14 Feb 2025 21:13:08 +0000 (13:13 -0800)
* src/cat.c (main): Don’t bother to try lseek on a fifo or socket,
as it will fail.

src/cat.c

index 92773d354f57ec1e8f8e7d647ff7795af23a283a..274f844a16a14959d60e65c28fcaa70ef5150e9a 100644 (file)
--- 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)
         {