Skip to content

Commit

Permalink
DPL: improve configuration detection (#5805)
Browse files Browse the repository at this point in the history
Do not poll for configuration if we do not have a pipe or
a regular file.
  • Loading branch information
ktf authored Mar 30, 2021
1 parent 7d86cc2 commit 6830856
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion Framework/Core/src/runDataProcessing.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1735,6 +1735,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 {
Expand Down Expand Up @@ -2086,7 +2099,8 @@ int doMain(int argc, char** argv, o2::framework::WorkflowSpec const& workflow,

std::vector<DataProcessorInfo> dataProcessorInfos;
CommandInfo commandInfo{};
if (isatty(STDIN_FILENO) == false) {

if (isatty(STDIN_FILENO) == false && isInputConfig()) {
std::vector<DataProcessorSpec> importedWorkflow;
WorkflowSerializationHelpers::import(std::cin, importedWorkflow, dataProcessorInfos, commandInfo);

Expand Down

0 comments on commit 6830856

Please sign in to comment.