1
0
Fork 0
mirror of https://gitlab.com/sortix/sortix.git synced 2023-02-13 20:55:38 -05:00
sortix--sortix/libc/string/strsignal.cpp

74 lines
2.5 KiB
C++
Raw Normal View History

2012-11-08 13:56:29 -05:00
/*******************************************************************************
Copyright(C) Jonas 'Sortie' Termansen 2012, 2014.
2012-11-08 13:56:29 -05:00
This file is part of the Sortix C Library.
2012-11-08 13:56:29 -05:00
The Sortix C Library is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or (at your
option) any later version.
2012-11-08 13:56:29 -05:00
The Sortix C Library 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 Lesser General Public
License for more details.
2012-11-08 13:56:29 -05:00
You should have received a copy of the GNU Lesser General Public License
along with the Sortix C Library. If not, see <http://www.gnu.org/licenses/>.
2012-11-08 13:56:29 -05:00
string/strsignal.cpp
Convert signal number to a string.
2012-11-08 13:56:29 -05:00
*******************************************************************************/
#define __SORTIX_STDLIB_REDIRECTS 0
#include <signal.h>
#include <string.h>
extern "C" const char* sortix_strsignal(int signum)
{
switch ( signum )
{
case SIGHUP: return "Hangup";
case SIGINT: return "Interrupt";
case SIGQUIT: return "Quit";
case SIGILL: return "Illegal instruction";
case SIGTRAP: return "Trace/breakpoint trap";
case SIGABRT: return "Aborted";
case SIGBUS: return "Bus Error";
case SIGFPE: return "Floating point exception";
case SIGKILL: return "Killed";
case SIGUSR1: return "User defined signal 1";
case SIGSEGV: return "Segmentation fault";
case SIGUSR2: return "User defined signal 2";
case SIGPIPE: return "Broken pipe";
case SIGALRM: return "Alarm clock";
case SIGTERM: return "Terminated";
case SIGSYS: return "Bad system call";
case SIGCHLD: return "Child exited";
case SIGCONT: return "Continued";
case SIGSTOP: return "Stopped (signal)";
case SIGTSTP: return "Stopped";
case SIGTTIN: return "Stopped (tty input)";
case SIGTTOU: return "Stopped (tty output)";
case SIGURG: return "Urgent I/O condition";
case SIGXCPU: return "CPU time limit exceeded";
case SIGXFSZ: return "File size limit exceeded";
case SIGVTALRM: return "Virtual timer expired";
case SIGPWR: return "Power Fail/Restart";
case SIGWINCH: return "Window changed";
default: break;
2012-11-08 13:56:29 -05:00
}
if ( SIGRTMIN <= signum && signum <= SIGRTMAX )
return "Real-time signal";
return "Unknown signal value";
2012-11-08 13:56:29 -05:00
}
extern "C" char* strsignal(int signum)
{
return (char*) sortix_strsignal(signum);
}