Source
/* On 32-bit GNU/Linux it is defined as 'int' (4 bytes). To print registers in a common way we print */
/*
** Copyright (C) 2001-2025 Zabbix SIA
**
** This program is free software: you can redistribute it and/or modify it under the terms of
** the GNU Affero General Public License as published by the Free Software Foundation, version 3.
**
** This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
** without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
** See the GNU Affero General Public License for more details.
**
** You should have received a copy of the GNU Affero General Public License along with this program.
** If not, see <https://www.gnu.org/licenses/>.
**/
/* required for getting a CPU program counter and registers in sys/ucontext.h */
const char *get_signal_name(int sig)
{
/* either strsignal() or sys_siglist[] could be used to */
/* get signal name, but these methods are not portable */
/* not all POSIX signals are available on all platforms, */
/* so we list only signals that we react to in our handlers */
switch (sig)
{
case SIGALRM: return "SIGALRM";
case SIGILL: return "SIGILL";
case SIGFPE: return "SIGFPE";
case SIGSEGV: return "SIGSEGV";
case SIGBUS: return "SIGBUS";
case SIGQUIT: return "SIGQUIT";
case SIGHUP: return "SIGHUP";
case SIGINT: return "SIGINT";
case SIGTERM: return "SIGTERM";
case SIGPIPE: return "SIGPIPE";
case SIGUSR1: return "SIGUSR1";
case SIGUSR2: return "SIGUSR2";
default: return "unknown";
}
}