Skip to content

Commit

Permalink
Merge pull request plumed#1095 from Iximiel/benchmark-signals
Browse files Browse the repository at this point in the history
Added sigterm to the signal handler for Benchmark
  • Loading branch information
GiovanniBussi authored Jul 24, 2024
2 parents 95e959f + d630967 commit 7401ac8
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/cltools/Benchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,11 @@ class SignalHandlerGuard {
extern "C" void signalHandler(int signal) {
if (signal == SIGINT) {
signalReceived.store(true);
fprintf(stderr, "Signal handler called\n");
fprintf(stderr, "Signal interrupt received\n");
}
if (signal == SIGTERM) {
signalReceived.store(true);
fprintf(stderr, "Signal termination received\n");
}
}

Expand Down Expand Up @@ -700,6 +704,7 @@ int Benchmark::main(FILE* in, FILE*out,Communicator& pc) {
log<<"Use CTRL+C to stop at any time and collect timers (not working in MPI runs)\n";
// trap signals:
SignalHandlerGuard sigIntGuard(SIGINT, signalHandler);
SignalHandlerGuard sigTermGuard(SIGTERM, signalHandler);

for(int step=0; nf<0 || step<nf; ++step) {
std::shuffle(kernels_ptr.begin(),kernels_ptr.end(),rng);
Expand Down

0 comments on commit 7401ac8

Please sign in to comment.