From db26e142d85621a5b79b1c1e44a909108637eaf7 Mon Sep 17 00:00:00 2001 From: Thomas Voss Date: Tue, 12 Nov 2024 12:14:10 +0100 Subject: Check for st.st_size > 0 --- src/work.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/work.c b/src/work.c index feb7c96..32962ff 100644 --- a/src/work.c +++ b/src/work.c @@ -92,7 +92,11 @@ process_file(const char *locl_filename, unsigned char **locl_buf) goto err; } - if (S_ISREG(st.st_mode)) { + /* We need to assert for st.st_size > 0 as some files (such as various files + under /proc on Linux) are generated ‘on the fly’ and will report a + filesize of 0. Despite being regular files, these files need to be + treated as if they are special. */ + if (S_ISREG(st.st_mode) && st.st_size > 0) { #if __linux__ (void)readahead(fd, 0, st.st_size); #endif -- cgit v1.2.3