summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2025-02-14 13:01:35 -0800
committerPaul Eggert <eggert@cs.ucla.edu>2025-02-14 13:13:08 -0800
commitdff821d3e392d7ac39c44eb5ded43ea91ced92f2 (patch)
tree5a7c9de36698bbc74db832ee8e1b11b9ed119941
parentcat: port to platforms with shm, tmo (diff)
downloadcoreutils-dff821d3e392d7ac39c44eb5ded43ea91ced92f2.tar.gz
coreutils-dff821d3e392d7ac39c44eb5ded43ea91ced92f2.zip
cat: omit unnecessary lseek
* src/cat.c (main): Don’t bother to try lseek on a fifo or socket, as it will fail.
-rw-r--r--src/cat.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/cat.c b/src/cat.c
index 92773d354..274f844a1 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)
{