SNode.C
Loading...
Searching...
No Matches
signal.cpp
Go to the documentation of this file.
1/*
2 * SNode.C - a slim toolkit for network communication
3 * Copyright (C) Volker Christian <me@vchrist.at>
4 * 2020, 2021, 2022, 2023, 2024, 2025
5 *
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public License as published
8 * by the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#ifndef DOXYGEN_SHOULD_SKIP_THIS
21
22#include "utils/system/signal.h"
23
24#include <cerrno>
25#include <map>
26#include <utility>
27
28#endif /* DOXYGEN_SHOULD_SKIP_THIS */
29
30namespace utils::system {
31
33 errno = 0;
34 return std::signal(sig, handler);
35 }
36
37 std::string sigabbrev_np(int sig) {
38 static std::map<int, std::string> sigMap = {
39 {SIGABRT, "ABRT"}, {SIGALRM, "ALRM"}, {SIGBUS, "BUS"}, {SIGCHLD, "CHLD"}, {SIGCONT, "CONT"}, {SIGFPE, "FPE"},
40 {SIGHUP, "HUP"}, {SIGILL, "ILL"}, {SIGINT, "INT"}, {SIGKILL, "KILL"}, {SIGPIPE, "PIPE"}, {SIGPOLL, "POLL"},
41 {SIGPROF, "PROF"}, {SIGQUIT, "QUIT"}, {SIGSEGV, "SEGV"}, {SIGSTOP, "STOP"}, {SIGSYS, "SYS"}, {SIGTERM, "TERM"},
42 {SIGTRAP, "TRAP"}, {SIGTSTP, "TSTP"}, {SIGTTIN, "TTIN"}, {SIGTTOU, "TTOU"}, {SIGUSR1, "USR1"}, {SIGUSR2, "USR2"},
43 {SIGURG, "URG"}, {SIGVTALRM, "VTALRM"}, {SIGXCPU, "XCPU"}, {SIGXFSZ, "XFSZ"}, {SIGWINCH, "WINCH"}};
44
45 return sigMap.contains(sig) ? sigMap[sig] : "UNKNOWN";
46 }
47
48} // namespace utils::system
sighandler_t signal(int sig, sighandler_t handler)
Definition signal.cpp:32
std::string sigabbrev_np(int sig)
Definition signal.cpp:37