66 auto itr = _rem->find(_type);
67 if(itr != _rem->end())
92 using match_t = std::pair<std::string, sys_signal>;
120 for(
const auto& itr : _list)
122 auto _enable =
get_env(
"SIGNAL_ENABLE_" + itr.first,
false);
123 auto _disable =
get_env(
"SIGNAL_DISABLE_" + itr.first,
false);
133 for(
const auto& itr : _list)
139 for(
const auto& itr : _list)
149 using descript_tuple_t = std::tuple<std::string, int, std::string>;
151 std::stringstream ss;
152 auto _descript = [&](
const descript_tuple_t& _data) {
153 ss <<
" Signal: " << std::setw(10) << std::get<0>(_data)
154 <<
" (error code: " << std::setw(3) << std::get<1>(_data) <<
") "
155 << std::setw(40) << std::get<2>(_data);
160 static std::vector<descript_tuple_t> descript_data = {
161 descript_tuple_t(
"SIGHUP", SIGHUP,
"terminal line hangup"),
162 descript_tuple_t(
"SIGINT", SIGINT,
"interrupt program"),
163 descript_tuple_t(
"SIGQUIT", SIGQUIT,
"quit program"),
164 descript_tuple_t(
"SIGILL", SIGILL,
"illegal instruction"),
165 descript_tuple_t(
"SIGTRAP", SIGTRAP,
"trace trap"),
166 descript_tuple_t(
"SIGABRT", SIGABRT,
"abort program (formerly SIGIOT)"),
167 descript_tuple_t(
"SIGEMT", SIGEMT,
"emulate instruction executed"),
168 descript_tuple_t(
"SIGFPE", SIGFPE,
"floating-point exception"),
169 descript_tuple_t(
"SIGKILL", SIGKILL,
"kill program"),
170 descript_tuple_t(
"SIGBUS", SIGBUS,
"bus error"),
171 descript_tuple_t(
"SIGSEGV", SIGSEGV,
"segmentation violation"),
172 descript_tuple_t(
"SIGSYS", SIGSYS,
"non-existent system call invoked"),
173 descript_tuple_t(
"SIGPIPE", SIGPIPE,
"write on a pipe with no reader"),
174 descript_tuple_t(
"SIGALRM", SIGALRM,
"real-time timer expired"),
175 descript_tuple_t(
"SIGTERM", SIGTERM,
"software termination signal"),
176 descript_tuple_t(
"SIGURG", SIGURG,
"urgent condition present on socket"),
177 descript_tuple_t(
"SIGSTOP", SIGSTOP,
"stop (cannot be caught or ignored)"),
178 descript_tuple_t(
"SIGTSTP", SIGTSTP,
"stop signal generated from keyboard"),
179 descript_tuple_t(
"SIGCONT", SIGCONT,
"continue after stop"),
180 descript_tuple_t(
"SIGCHLD", SIGCHLD,
"child status has changed"),
181 descript_tuple_t(
"SIGTTIN", SIGTTIN,
182 "background read attempted from control terminal"),
183 descript_tuple_t(
"SIGTTOU", SIGTTOU,
184 "background write attempted to control terminal"),
185 descript_tuple_t(
"SIGIO ", SIGIO,
"I/O is possible on a descriptor"),
186 descript_tuple_t(
"SIGXCPU", SIGXCPU,
"cpu time limit exceeded"),
187 descript_tuple_t(
"SIGXFSZ", SIGXFSZ,
"file size limit exceeded"),
188 descript_tuple_t(
"SIGVTALRM", SIGVTALRM,
"virtual time alarm"),
189 descript_tuple_t(
"SIGPROF", SIGPROF,
"profiling timer alarm"),
190 descript_tuple_t(
"SIGWINCH", SIGWINCH,
"Window size change"),
191 descript_tuple_t(
"SIGINFO", SIGINFO,
"status request from keyboard"),
192 descript_tuple_t(
"SIGUSR1", SIGUSR1,
"User defined signal 1"),
193 descript_tuple_t(
"SIGUSR2", SIGUSR2,
"User defined signal 2")
196 int key = (int) _type;
197 for(
const auto& itr : descript_data)
199 if(std::get<1>(itr) == key)
214 std::stringstream ss;
215 auto spacer = []() {
return " "; };
217#if defined(SIGNAL_AVAILABLE)
220 << spacer() <<
"Signal detection activated. Signal exception settings:\n"
224 ss << spacer() <<
"Enabled:" << std::endl;
225 for(
const auto& itr :
f_signals().signals_enabled)
230 ss <<
"\n" << spacer() <<
"Disabled:" << std::endl;
231 for(
const auto& itr :
f_signals().signals_disabled)
237 ss << std::endl << spacer() <<
"Signal detection not available" << std::endl;
239 (void) report_disabled;
static std::string str(const sys_signal &)
static void enable(const sys_signal &)
static void check_environment()
static void exit_action(int errcode)
static bool & enable_all()
static void disable(const sys_signal &)
static signal_set_t get_enabled()
std::set< sys_signal > signal_set_t
std::function< void(int)> signal_function_t
static void set_active(bool val)
static signal_set_t get_disabled()
static void set_exit_action(signal_function_t _f)
static bool & disable_all()
static signal_set_t get_default()
static signals_data & f_signals()
void insert_and_remove(const sys_signal &_type, signal_settings::signal_set_t *_ins, signal_settings::signal_set_t *_rem)
Tp get_env(const std::string &env_id, Tp _default, bool _store)
tim::mpl::apply< std::string > string
signal_set_t signals_default
signal_set_t signals_disabled
signal_function_t signals_exit_func
signal_set_t signals_enabled
The declaration for the types for utility without definitions.