Skip to content

Commit 6830856

Browse files
authored
DPL: improve configuration detection (#5805)
Do not poll for configuration if we do not have a pipe or a regular file.
1 parent 7d86cc2 commit 6830856

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

Framework/Core/src/runDataProcessing.cxx

+15-1
Original file line numberDiff line numberDiff line change
@@ -1735,6 +1735,19 @@ bool isOutputToPipe()
17351735
return ((s.st_mode & S_IFIFO) != 0);
17361736
}
17371737

1738+
bool isInputConfig()
1739+
{
1740+
struct stat s;
1741+
int r = fstat(STDIN_FILENO, &s);
1742+
// If stdin cannot be statted, we assume the shell is some sort of
1743+
// non-interactive container thing
1744+
if (r < 0) {
1745+
return false;
1746+
}
1747+
// If stdin is a pipe or a file, we try to fetch configuration from there
1748+
return ((s.st_mode & S_IFIFO) != 0 || (s.st_mode & S_IFREG) != 0);
1749+
}
1750+
17381751
void overrideCloning(ConfigContext& ctx, WorkflowSpec& workflow)
17391752
{
17401753
struct CloningSpec {
@@ -2086,7 +2099,8 @@ int doMain(int argc, char** argv, o2::framework::WorkflowSpec const& workflow,
20862099

20872100
std::vector<DataProcessorInfo> dataProcessorInfos;
20882101
CommandInfo commandInfo{};
2089-
if (isatty(STDIN_FILENO) == false) {
2102+
2103+
if (isatty(STDIN_FILENO) == false && isInputConfig()) {
20902104
std::vector<DataProcessorSpec> importedWorkflow;
20912105
WorkflowSerializationHelpers::import(std::cin, importedWorkflow, dataProcessorInfos, commandInfo);
20922106

0 commit comments

Comments
 (0)