cat: don’t trust st_size on /proc files
commit225cb8d7473eadb481a4884e929bf23589d4bd82
authorPaul Eggert <eggert@cs.ucla.edu>
Sat, 6 Apr 2024 22:13:23 +0000 (6 15:13 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Sat, 6 Apr 2024 22:18:27 +0000 (6 15:18 -0700)
tree5671b6b7079867971d3ccaf70165763bd27a9b08
parent8f3989d586a88d182700050b435d2f6c393ec27b
cat: don’t trust st_size on /proc files

* src/cat.c (main):
Improve test for when copying will exhaust the output device.
Do not rely on st_size, which is unreliable in /proc.
Use lseek instead; this is good enough here.
* tests/cat/cat-self.sh: Test the relaxation of the heuristic
for self-copying.
src/cat.c
tests/cat/cat-self.sh