From 78474b29356450e3abfcbaa2935976a09cd996e9 Mon Sep 17 00:00:00 2001 From: Christopher Jones Date: Mon, 13 Sep 2021 09:50:19 -0500 Subject: [PATCH] Change current path in cmsExternalGenerator not cmsRun When doing concurrent beginStreams, changing of the current path was causing interference between threads. --- GeneratorInterface/Core/bin/externalGenerator.cc | 8 ++++++++ .../Core/plugins/ExternalGeneratorFilter.cc | 7 ------- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/GeneratorInterface/Core/bin/externalGenerator.cc b/GeneratorInterface/Core/bin/externalGenerator.cc index fb8722415842d..08ed2d0eb8374 100644 --- a/GeneratorInterface/Core/bin/externalGenerator.cc +++ b/GeneratorInterface/Core/bin/externalGenerator.cc @@ -6,6 +6,7 @@ #include #include #include +#include #include "FWCore/TestProcessor/interface/TestProcessor.h" @@ -137,6 +138,13 @@ int main(int argc, char* argv[]) { return 1; } + using namespace std::string_literals; + using namespace std::filesystem; + + auto newDir = path("thread"s + vm[kUniqueIDOpt].as()); + create_directory(newDir); + current_path(newDir); + WorkerMonitorThread monitorThread; monitorThread.startThread(); diff --git a/GeneratorInterface/Core/plugins/ExternalGeneratorFilter.cc b/GeneratorInterface/Core/plugins/ExternalGeneratorFilter.cc index 2436ef977b565..9a8960f10fdb7 100644 --- a/GeneratorInterface/Core/plugins/ExternalGeneratorFilter.cc +++ b/GeneratorInterface/Core/plugins/ExternalGeneratorFilter.cc @@ -46,22 +46,15 @@ namespace externalgen { channel_.setupWorker([&]() { using namespace std::string_literals; - using namespace std::filesystem; edm::LogSystem("ExternalProcess") << id_ << " starting external process \n"; std::string verboseCommand; if (verbose) { verboseCommand = "--verbose "; } - auto curDir = current_path(); - auto newDir = path("thread"s + std::to_string(id_)); - create_directory(newDir); - current_path(newDir); pipe_ = popen(("cmsExternalGenerator "s + verboseCommand + channel_.sharedMemoryName() + " " + channel_.uniqueID()) .c_str(), "w"); - current_path(curDir); - if (nullptr == pipe_) { abort(); }