00001 // -*- c++ -*- 00002 //------------------------------------------------------------------------------ 00003 // SigHandler.h 00004 //------------------------------------------------------------------------------ 00005 // Copyright (c) 1997 by Vladislav Grinchenko 00006 // 00007 // This library is free software; you can redistribute it and/or 00008 // modify it under the terms of the GNU Library General Public 00009 // License as published by the Free Software Foundation; either 00010 // version 2 of the License, or (at your option) any later version. 00011 //------------------------------------------------------------------------------ 00012 #ifndef _SigHandler_h 00013 #define _SigHandler_h 00014 00015 // System includes 00016 00017 #include <signal.h> 00018 #include <errno.h> 00019 00020 #include "assa/Logger.h" 00021 #include "assa/IdSet.h" 00022 #include "assa/SigSet.h" 00023 #include "assa/SigAction.h" 00024 #include "assa/EventHandler.h" 00025 00026 namespace ASSA { 00027 00028 #if !defined(WIN32) 00029 00049 class SigHandler 00050 { 00051 public: 00067 virtual int install (int signum_, 00068 EventHandler* new_hand_, 00069 SigAction* new_disp_ = 0, 00070 EventHandler** old_hand_ = 0, 00071 SigAction* old_disp_ = 0); 00072 00085 virtual int remove (int signum_, 00086 EventHandler* eh_ = 0, 00087 SigAction* new_disp_ = 0, 00088 SigAction* old_disp_ = 0); 00089 00099 static void dispatch (int signum_); 00100 00107 EventHandler* handler (int signum_, EventHandler* new_); 00108 00111 EventHandler* handler (int signum_); 00112 00113 protected: 00117 int in_range(int signum_); 00118 00119 private: 00123 static EventHandler* m_signal_handlers [NSIG]; 00124 }; 00125 00126 #endif // !defined(WIN32) 00127 00128 } // end namespace ASSA 00129 00130 #endif /* _SigHandler_h */