00001 00013 /*************************************************************************** 00014 * Copyright (C) 2007 by Jan Koci * 00015 * honza.koci@email.cz * 00016 * http://kengine.sourceforge.net/tutorial/ 00017 * * 00018 * This program is free software; you can redistribute it and/or modify * 00019 * it under the terms of the GNU General Public License as published by * 00020 * the Free Software Foundation; either version 2 of the License, or * 00021 * (at your option) any later version. * 00022 * * 00023 * This program is distributed in the hope that it will be useful, * 00024 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00025 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00026 * GNU General Public License for more details. * 00027 * * 00028 * You should have received a copy of the GNU General Public License * 00029 * along with this program; if not, write to the * 00030 * Free Software Foundation, Inc., * 00031 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 00032 ***************************************************************************/ 00033 00034 00035 #pragma once 00036 00037 #include <csignal> 00038 #include <sstream> 00039 #include <iostream> 00040 using namespace std; 00041 #include <sys/wait.h> 00042 00046 class KjSignal 00047 { 00048 struct sigaction m_tSa; 00049 00050 int m_iCatchSignal; 00051 void (*m_pFunction) (int); 00052 static bool m_bIsSigInt; 00053 static bool m_bIsSigQuit; 00054 00055 void InitSignal(const int _iSignalId); 00056 static void CheckSignal(const int _iSignalId); 00057 static void SigIntHandler(const int _iSignalI); 00058 static void SigQuitHandler(const int _iSignalI); 00059 static void SigChldHandler(const int _iSignalId); 00060 00061 public: 00062 KjSignal(); 00063 ~KjSignal(); 00064 00065 bool IsSigInt() 00066 { 00067 return m_bIsSigInt; 00068 } 00069 00070 bool IsSigQuit() 00071 { 00072 return m_bIsSigQuit; 00073 } 00074 00075 void InitSignals(); 00076 }; 00077