Révision | 20745f4b8ed9fb6f20df83143a686eecb0112936 (tree) |
---|---|
l'heure | 2013-01-25 16:59:16 |
Auteur | Katsuhiko Nishimra <ktns.87@gmai...> |
Commiter | Katsuhiko Nishimra |
tmp Exit when caught signal
@@ -18,6 +18,7 @@ | ||
18 | 18 | //************************************************************************// |
19 | 19 | #include<stdio.h> |
20 | 20 | #include<stdlib.h> |
21 | +#include<signal.h> | |
21 | 22 | #include<iostream> |
22 | 23 | #include<vector> |
23 | 24 | #include<stdexcept> |
@@ -30,7 +31,19 @@ | ||
30 | 31 | #include"base/Molecule.h" |
31 | 32 | #include"base/MolDS.h" |
32 | 33 | using namespace std; |
34 | + | |
35 | +void my_signal_handler(int signal){ | |
36 | + cerr << "Caught signal " << signal << "!" << endl << flush; | |
37 | + cout << flush; | |
38 | + exit(1); | |
39 | +} | |
40 | + | |
33 | 41 | int main(int argc, char *argv[]){ |
42 | + signal(SIGINT, my_signal_handler); | |
43 | + signal(SIGTERM, my_signal_handler); | |
44 | + signal(SIGHUP, my_signal_handler); | |
45 | + signal(SIGILL, my_signal_handler); | |
46 | + signal(SIGABRT, my_signal_handler); | |
34 | 47 | try{ |
35 | 48 | boost::shared_ptr<MolDS_base::MolDS> molds(new MolDS_base::MolDS()); |
36 | 49 | molds->Run(argc, argv); |