Skip to content

Commit

Permalink
stop SNiPER when Ctrl+C is received
Browse files Browse the repository at this point in the history
  • Loading branch information
zoujh committed Sep 22, 2020
1 parent 9abffff commit 7a9f0bf
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions SniperKernel/src/binding/PythonCapsul.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,19 @@
#include "NonUserIf/DLEFactory.h"
#include <iostream>
#include <fstream>
#include <signal.h>

void sniper_sig_handler(int signum)
{
switch(signum) {
case SIGINT:
sniper_context.reg_msg("SNiPER is stopped by Ctrl+C");
std::cout << "SNiPER is stopped by Ctrl+C" << std::endl;
exit(0);
default:
; //pass
}
}

void Sniper::python_capsul()
{
Expand All @@ -37,6 +50,7 @@ void Sniper::python_capsul()
<< "**************************************************\n"
<< "Running @ " << System::hostName()
<< " on " << System::sysDate();
sigset(SIGINT, sniper_sig_handler);
}

~PythonCapsul() {
Expand Down

0 comments on commit 7a9f0bf

Please sign in to comment.