Signal.cpp
Go to the documentation of this file.
00001 // -*- C++ -*-
00020 #include <coil/config_coil.h>
00021 #include <coil/Signal.h>
00022 #include <string.h>
00023 
00024 #ifdef COIL_OS_FREEBSD
00025 #define _SIGSET_NWORDS _SIG_WORDS
00026 #endif
00027 
00028 namespace coil
00029 {
00037   SignalAction::SignalAction()
00038     : m_handle(0), m_signum(0), m_mask(0), m_flags(0)
00039   {
00040   }
00041 
00053   SignalAction::SignalAction(SignalHandler handle, int signum)
00054     : m_handle(handle), m_signum(signum), m_mask(0), m_flags(0)
00055   {
00056     struct sigaction action;
00057     memset(&action, 0, sizeof(action));  // clear.
00058     action.sa_handler = m_handle;
00059 
00060     signal(m_signum, SIG_IGN);
00061     if (sigaction(m_signum, &action, 0) < 0)
00062       {
00063         signal(m_signum, SIG_DFL);
00064         m_handle = 0;
00065         m_signum = 0;
00066         m_mask   = 0;
00067         m_flags  = 0;
00068       }
00069   }
00070 
00078   SignalAction::~SignalAction()
00079   {
00080     signal(m_signum, SIG_DFL);
00081     m_handle = 0;
00082     m_signum = 0;
00083     m_mask   = 0;
00084     m_flags  = 0;
00085   }
00086 
00087 };


openrtm_aist
Author(s): Noriaki Ando
autogenerated on Sat Jun 8 2019 18:49:07