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 00047 class SigHandler 00048 { 00049 public: 00065 virtual int install (int signum_, 00066 EventHandler* new_hand_, 00067 SigAction* new_disp_ = 0, 00068 EventHandler** old_hand_ = 0, 00069 SigAction* old_disp_ = 0); 00070 00083 virtual int remove (int signum_, 00084 EventHandler* eh_ = 0, 00085 SigAction* new_disp_ = 0, 00086 SigAction* old_disp_ = 0); 00087 00097 static void dispatch (int signum_); 00098 00105 EventHandler* handler (int signum_, EventHandler* new_); 00106 00109 EventHandler* handler (int signum_); 00110 00111 protected: 00115 int in_range(int signum_); 00116 00117 private: 00121 static EventHandler* m_signal_handlers [NSIG]; 00122 }; 00123 00124 } // end namespace ASSA 00125 00126 #endif /* _SigHandler_h */