File indexing completed on 2025-01-18 09:14:41
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 #include "DD4hep/DetFactoryHelper.h"
0016 #include "DD4hep/SignalHandler.h"
0017 #include "DD4hep/Printout.h"
0018
0019
0020 #include <cstdio>
0021 #include <csignal>
0022 #include <unistd.h>
0023
0024 using namespace dd4hep;
0025
0026 static bool signal_handler(void* user_context, int signal) {
0027 printout(ALWAYS,"SignalHandler",
0028 "+++ Caught signal: %d context: %p. exit process.",
0029 signal, user_context);
0030 ::fflush(stdout);
0031 ::exit(EINVAL);
0032 return true;
0033 }
0034
0035 static Ref_t create_detector(Detector& , xml_h e, SensitiveDetector ) {
0036
0037 xml_dim_t x_det = e;
0038
0039 DetElement d_det(x_det.nameStr(),x_det.id());
0040
0041 SignalHandler handler;
0042 handler.registerHandler(SIGINT, (void*)0xFEEDBABE, signal_handler);
0043
0044 printout(ALWAYS,"SignalTrigger","+++ Sending interrupt signal to self...");
0045 ::kill(::getpid(), SIGINT);
0046
0047 return d_det;
0048 }
0049
0050 DECLARE_DETELEMENT(InterruptTrigger,create_detector)