refactored handleSignal
[physics.git] / src / handleSignal.cpp
index 5677e9e..cd1fcec 100644 (file)
@@ -1,16 +1,35 @@
+/*
+ *  Copyright (C) 2008 Patrik Gornicz, Gornicz_P (at) hotmail (dot) com.
+ *
+ *  This program is free software: you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation, either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
 #include "handleSignal.h"
 
 #include <iostream>
 #include <signal.h>
+#include <stdlib.h>
 
 /// ***** Private Method Headers *****
 
-void sighandler( int sig );
+static void sighandler( int iSig );
 
 /// ***** Public Methods *****
 
 void installSignal()
 {
+#ifndef __WIN32__
     // register signal handler
     struct sigaction sa;
     sigemptyset( &sa.sa_mask );
@@ -21,14 +40,16 @@ void installSignal()
     {
         std::cerr << "could not install SIGINT handler" << std::endl;
     }
+#endif // __WIN32__
 }
 
 /// ***** Private Methods *****
 
 // signal handler function
-void sighandler( int sig )
+void sighandler( int iSig )
 {
-    switch(sig)
+#ifndef __WIN32__
+    switch(iSig)
     {
         case SIGINT:
             std::cerr << "SIGINT caught" << std::endl;
@@ -38,5 +59,6 @@ void sighandler( int sig )
     }
 
     // normally an abort is better ... but this is just SIGINT
-    exit(sig);
+    exit(iSig);
+#endif // __WIN32__
 }