massive cleaning of file section headers
[physics.git] / src / handleSignal.cpp
CommitLineData
7cbd4505
PG
1#include "handleSignal.h"
2
3#include <iostream>
4#include <signal.h>
5
6/// ***** Private Method Headers *****
7cbd4505 7
617dcc71 8void sighandler( int sig );
7cbd4505
PG
9
10/// ***** Public Methods *****
11
12void installSignal()
13{
14 // register signal handler
15 struct sigaction sa;
16 sigemptyset( &sa.sa_mask );
17 sa.sa_handler = sighandler;
18 sa.sa_flags = 0;
19
20 if ( sigaction( SIGINT, &sa, NULL ) < 0 )
21 {
22 std::cerr << "could not install SIGINT handler" << std::endl;
23 }
24}
25
26/// ***** Private Methods *****
27
28// signal handler function
29void sighandler( int sig )
30{
31 switch(sig)
32 {
33 case SIGINT:
34 std::cerr << "SIGINT caught" << std::endl;
35 break;
36 default:
37 std::cout << "UNKNOWN caught";
38 }
39
40 // normally an abort is better ... but this is just SIGINT
41 exit(sig);
42}