From 900b9c31f72027d1c00452046720773dd9154ac6 Mon Sep 17 00:00:00 2001 From: Michael Beavitt Date: Thu, 9 Jul 2026 18:02:20 +0100 Subject: [PATCH] Add additional checks for non-seekable input Pre-preocessing checks for adapters etc. by reading some of the input then rewinding the file, and this is turned off for /dev/stdin explicitly because rewinds won't work. Unfortunately, this doesn't catch process substitution inputs (e.g. `<(zcat file.fq.gz)`) which then silently drop data when the rewinds fail. This commit introduces a new helper function which checks whether the file descriptor is rewindable, turning off evaluation if not. --- src/main.cpp | 4 +++- src/util.h | 9 +++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 9e5b015c..07248508 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -434,7 +434,9 @@ int main(int argc, char* argv[]){ time_t t1 = time(NULL); - bool supportEvaluation = !opt.inputFromSTDIN && opt.in1!="/dev/stdin"; + bool supportEvaluation = !opt.inputFromSTDIN && opt.in1!="/dev/stdin" + && is_regular_file(opt.in1) + && (opt.in2.empty() || is_regular_file(opt.in2)); Evaluator eva(&opt); if(supportEvaluation) { diff --git a/src/util.h b/src/util.h index 62f582b9..0797559f 100644 --- a/src/util.h +++ b/src/util.h @@ -182,6 +182,15 @@ inline bool is_directory(const string& path) return isdir; } +// check if a path is a regular file (seekable), not a pipe/FIFO/device +inline bool is_regular_file(const string& path) +{ + struct stat status; + if( stat( path.c_str(), &status ) != 0 ) + return false; + return S_ISREG( status.st_mode ); +} + inline void check_file_valid(const string& s) { if(!file_exists(s)){ cerr << "ERROR: file '" << s << "' doesn't exist, quit now" << endl;