From 55233b9f72073911c915068d4ac8e25b3b773eb0 Mon Sep 17 00:00:00 2001 From: Giulio Eulisse <10544+ktf@users.noreply.github.com> Date: Fri, 26 Mar 2021 10:52:27 +0100 Subject: [PATCH] DPL: improve configuration detection Do not poll for configuration if we do not have a pipe or a regular file. --- Framework/Core/src/runDataProcessing.cxx | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/Framework/Core/src/runDataProcessing.cxx b/Framework/Core/src/runDataProcessing.cxx index 0d42ca701ff01..a3ae33dca3f12 100644 --- a/Framework/Core/src/runDataProcessing.cxx +++ b/Framework/Core/src/runDataProcessing.cxx @@ -1734,6 +1734,19 @@ bool isOutputToPipe() return ((s.st_mode & S_IFIFO) != 0); } +bool isInputConfig() +{ + struct stat s; + int r = fstat(STDIN_FILENO, &s); + // If stdin cannot be statted, we assume the shell is some sort of + // non-interactive container thing + if (r < 0) { + return false; + } + // If stdin is a pipe or a file, we try to fetch configuration from there + return ((s.st_mode & S_IFIFO) != 0 || (s.st_mode & S_IFREG) != 0); +} + void overrideCloning(ConfigContext& ctx, WorkflowSpec& workflow) { struct CloningSpec { @@ -2085,7 +2098,8 @@ int doMain(int argc, char** argv, o2::framework::WorkflowSpec const& workflow, std::vector dataProcessorInfos; CommandInfo commandInfo{}; - if (isatty(STDIN_FILENO) == false) { + + if (isatty(STDIN_FILENO) == false && isInputConfig()) { std::vector importedWorkflow; WorkflowSerializationHelpers::import(std::cin, importedWorkflow, dataProcessorInfos, commandInfo);