libassa 3.5.0
|
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: 00054 virtual ~SigHandler () { /* no-op */ } 00055 00071 virtual int install (int signum_, 00072 EventHandler* new_hand_, 00073 SigAction* new_disp_ = 0, 00074 EventHandler** old_hand_ = 0, 00075 SigAction* old_disp_ = 0); 00076 00089 virtual int remove (int signum_, 00090 EventHandler* eh_ = 0, 00091 SigAction* new_disp_ = 0, 00092 SigAction* old_disp_ = 0); 00093 00103 static void dispatch (int signum_); 00104 00111 EventHandler* handler (int signum_, EventHandler* new_); 00112 00115 EventHandler* handler (int signum_); 00116 00117 protected: 00121 int in_range(int signum_); 00122 00123 private: 00127 static EventHandler* m_signal_handlers [NSIG]; 00128 }; 00129 00130 #endif // !defined(WIN32) 00131 00132 } // end namespace ASSA 00133 00134 #endif /* _SigHandler_h */