Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:13:07

0001 // -*- C++ -*-
0002 //
0003 // Package:     FWCore/Services/test
0004 // Class  :     SignallingAnalyzer
0005 //
0006 // Implementation:
0007 //     [Notes on implementation]
0008 //
0009 // Original Author:  Chris Jones
0010 //         Created:  Sat, 22 Mar 2014 23:07:05 GMT
0011 //
0012 
0013 // system include files
0014 
0015 // user include files
0016 #include "FWCore/Framework/interface/global/EDAnalyzer.h"
0017 #include "FWCore/Framework/interface/MakerMacros.h"
0018 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0019 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0020 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0021 #include "FWCore/ParameterSet/interface/allowedValues.h"
0022 #include <csignal>
0023 
0024 class SignallingAnalyzer : public edm::global::EDAnalyzer<> {
0025 public:
0026   SignallingAnalyzer(edm::ParameterSet const& iPSet) : m_signal(iPSet.getUntrackedParameter<std::string>("signal")) {}
0027 
0028   void analyze(edm::StreamID, edm::Event const&, edm::EventSetup const&) const final {
0029     if (m_signal == "INT") {
0030       raise(SIGINT);
0031     }
0032     if (m_signal == "ABRT") {
0033       raise(SIGABRT);
0034     }
0035     if (m_signal == "SEGV") {
0036       raise(SIGSEGV);
0037     }
0038     if (m_signal == "TERM") {
0039       raise(SIGTERM);
0040     }
0041   }
0042 
0043   static void fillDescriptions(edm::ConfigurationDescriptions& iConf) {
0044     edm::ParameterSetDescription desc;
0045     desc.ifValue(edm::ParameterDescription<std::string>("signal", "INT", false),
0046                  edm::allowedValues<std::string>("INT", "ABRT", "SEGV", "TERM"))
0047         ->setComment("which signal to raise.");
0048     iConf.addDefault(desc);
0049   }
0050 
0051 private:
0052   std::string const m_signal;
0053 };
0054 
0055 DEFINE_FWK_MODULE(SignallingAnalyzer);