10 #include "GaudiKernel/IEvtSelector.h" 
   11 #include "GaudiKernel/IIoComponentMgr.h" 
   12 #include "GaudiKernel/IFileMgr.h" 
   13 #include "GaudiKernel/IMessageSvc.h" 
   34                    , 
const std::string& 
name 
   35                    , 
const IInterface* 
parent)
 
   37   , m_evtProcessor(
"AthenaEventLoopMgr",
name)
 
   38   , m_appMgr(
"ApplicationMgr",
name)
 
   39   , m_fileMgr(
"FileMgr",
name)
 
   40   , m_ioMgr(
"IoComponentMgr",
name)
 
   63   SmartIF<IProperty> prpMgr(serviceLocator());
 
   64   if(prpMgr.isValid()) {
 
   74     ATH_MSG_ERROR(
"IProperty interface not found in ApplicationMgr");
 
   75     return StatusCode::FAILURE;
 
   80   SmartIF<IProperty> prpMgr1(
m_fileMgr.get());
 
   82   m_fileMgrLog = prpMgr1->getProperty(
"LogFile").toString();
 
   84   return StatusCode::SUCCESS;
 
   89   return StatusCode::SUCCESS;
 
   98     return StatusCode::SUCCESS;
 
  107     return StatusCode::FAILURE;
 
  124     ATH_MSG_WARNING(
name() << 
" cannot make output report because FileMgr has not been configured to write log file!");
 
  131       std::ostringstream workindex;
 
  144       std::ifstream inpStream(
logFile.string().c_str());
 
  145       std::set<std::string> reportedFiles; 
 
  146       while(!inpStream.eof()) {
 
  147     std::getline(inpStream,
line);
 
  148         if(
line.find(
"WRITE")!=std::string::npos) {
 
  151       std::vector<std::string> 
entries;
 
  152           while(startpos<
line.size()) {
 
  153             while(
line[startpos]==
' ')
 
  156             size_t endpos = 
line.find(
' ',startpos);
 
  157             if(endpos==std::string::npos) endpos = 
line.size();
 
  158             entries.push_back(
line.substr(startpos,endpos-startpos));
 
  165           if(reportedFiles.find(
basename.string())==reportedFiles.end())
 
  166             reportedFiles.insert(
basename.string());
 
  171           if(it1==jobOutputs->end()) {
 
  177           newOutput.
filename = absolutename.string();
 
  181           newOutput.
shared = (
line.find(
"SHARED")!=std::string::npos);
 
  183           (*jobOutputs)[
basename.string()].emplace_back(std::move(newOutput));
 
  204     kill(child.getProcessID(),SIGKILL);
 
  210   std::unique_ptr<AthenaInterprocess::ScheduledWork> outwork;
 
  247     *(
int*)(outwork->
data) = 1; 
 
  254 int AthenaMPToolBase::mapAsyncFlag(Func_Flag 
flag, 
pid_t pid)
 
  263       ATH_MSG_ERROR(
"Unable to map the flag on all subprocesses in the group");
 
  272   int dup2result1(0), dup2result2(0);
 
  274   int newout = 
open(std::string(
rundir+
"/AthenaMP.log").c_str(),O_CREAT | O_RDWR, S_IRWXU|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH);
 
  279   dup2result1 = dup2(newout, STDOUT_FILENO);
 
  280   dup2result2 = dup2(newout, STDERR_FILENO);
 
  281   TEMP_FAILURE_RETRY(close(newout));
 
  282   if(dup2result1==-1) {
 
  286   if(dup2result2==-1) {
 
  292     SmartIF<IProperty> propertyServer(
msgSvc());
 
  293     if(propertyServer==0) {
 
  298     std::string propertyName(
"Format");
 
  299     std::string oldFormat(
"");
 
  300     StringProperty formatProp(propertyName,oldFormat);
 
  301     StatusCode sc = propertyServer->getProperty(&formatProp);
 
  306       oldFormat = formatProp.value();
 
  307       if(oldFormat.find(
"%t")==std::string::npos) {
 
  309         std::string newFormat(
"%t " + oldFormat);
 
  310         StringProperty newFormatProp(std::move(propertyName),newFormat);
 
  311         ATH_CHECK(propertyServer->setProperty(newFormatProp), -1);
 
  314         ATH_MSG_DEBUG(
"MsgSvc format already contains timestamps. Nothing to be done");
 
  336   strerror_r(errnum, buf, 
sizeof(buf));
 
  337   return std::string(buf);
 
  348   std::vector<const Io::FileAttr*> filemgrFiles;
 
  349   std::vector<const Io::FileAttr*>::const_iterator itFile;
 
  350   unsigned filenum = 
m_fileMgr->getFiles(filemgrFiles); 
 
  351   if(filenum!=filemgrFiles.size())
 
  352     ATH_MSG_WARNING(
"getFiles returned " << filenum << 
" while vector size is " << filemgrFiles.size());
 
  354   for(itFile=filemgrFiles.begin();itFile!=filemgrFiles.end();++itFile) {
 
  356     const std::string& 
filename = (**itFile).name();
 
  363       ATH_MSG_WARNING(
"FD=-1 detected on an open file retrieved from FileMgr. Skip FD reopening. File name: " << 
filename);
 
  375     if(fdLog.find(regEntry.fd)!=fdLog.end()) {
 
  376       ATH_MSG_DEBUG(
"The file from FdsRegistry " << regEntry.name << 
" was registered with FileMgr. Skip reopening");
 
  379       ATH_MSG_WARNING(
"The file " << regEntry.name << 
" has not been registered with the FileMgr!");
 
  381       if(regEntry.fd==-1) {
 
  383     ATH_MSG_WARNING(
"FD=-1 detected on an open file retrieved from FD Registry. Skip FD reopening. File name: " << regEntry.name);
 
  387       if(
reopenFd(regEntry.fd,regEntry.name))
 
  390       fdLog.insert(regEntry.fd);
 
  398   if(std::filesystem::is_regular_file(
"PoolFileCatalog.xml.AthenaMP-saved"))
 
  399     COPY_FILE_HACK(
"PoolFileCatalog.xml.AthenaMP-saved",dest_path.string()+
"/PoolFileCatalog.xml");
 
  405   ATH_MSG_INFO(
"Bootstrap worker PID " << getpid() << 
" - waiting for SIGUSR1");
 
  413   sigprocmask (SIG_BLOCK, &
mask, &oldmask);
 
  415     sigsuspend (&oldmask);
 
  416   sigprocmask (SIG_UNBLOCK, &
mask, NULL);
 
  422   int old_openflags = fcntl(
fd,F_GETFL,0);
 
  423   switch(old_openflags & O_ACCMODE) {
 
  438   int old_descflags = fcntl(
fd,F_GETFD,0);
 
  439   off_t oldpos = lseek(
fd,0,SEEK_CUR);
 
  455     if(lseek(newfd,oldpos,SEEK_SET)==-1){
 
  457       TEMP_FAILURE_RETRY(close(newfd));
 
  460     TEMP_FAILURE_RETRY(close(
fd));
 
  461     if(dup2(newfd,
fd)==-1) {
 
  462       ATH_MSG_ERROR(
"When re-opening file descriptors unable to duplicate descriptor for " << 
name << 
". " << 
fmterror(errno));
 
  463       TEMP_FAILURE_RETRY(close(newfd));
 
  466     if(fcntl(
fd,F_SETFD,old_descflags)==-1) {
 
  467       ATH_MSG_ERROR(
"When re-opening file descriptors unable to set descriptor flags for " << 
name << 
". " << 
fmterror(errno));
 
  468       TEMP_FAILURE_RETRY(close(newfd));
 
  471     TEMP_FAILURE_RETRY(close(newfd));