xref: /haiku/src/system/libroot/posix/signal/strsignal.cpp (revision ae9019359606f1db67632ef51a77ce70001d3770)
124df6592SIngo Weinhold /*
224df6592SIngo Weinhold  * Copyright 2002-2011, Haiku, Inc. All rights reserved.
324df6592SIngo Weinhold  * Distributed under the terms of the MIT license.
424df6592SIngo Weinhold  *
524df6592SIngo Weinhold  * Author:
624df6592SIngo Weinhold  *		Daniel Reinhold (danielre@users.sf.net)
724df6592SIngo Weinhold  *		Ingo Weinhold, ingo_weinhold@gmx.de
824df6592SIngo Weinhold  */
924df6592SIngo Weinhold 
1024df6592SIngo Weinhold 
1124df6592SIngo Weinhold #include <string.h>
1224df6592SIngo Weinhold 
1324df6592SIngo Weinhold #include <errno.h>
1424df6592SIngo Weinhold #include <signal.h>
1524df6592SIngo Weinhold #include <stdio.h>
1624df6592SIngo Weinhold 
17*ae901935SOliver Tappe #include <errno_private.h>
1824df6592SIngo Weinhold #include <signal_defs.h>
1924df6592SIngo Weinhold 
2024df6592SIngo Weinhold 
2124df6592SIngo Weinhold static const char* const kInvalidSignalNumberText = "Bogus signal number";
2224df6592SIngo Weinhold 
2324df6592SIngo Weinhold 
2424df6592SIngo Weinhold const char * const
2524df6592SIngo Weinhold sys_siglist[NSIG] = {
2624df6592SIngo Weinhold 	/*  0 */				"Signal 0",
2724df6592SIngo Weinhold 	/*  1 - SIGHUP */		"Hangup",
2824df6592SIngo Weinhold 	/*  2 - SIGINT  */		"Interrupt",
2924df6592SIngo Weinhold 	/*  3 - SIGQUIT */		"Quit",
3024df6592SIngo Weinhold 	/*  4 - SIGILL */		"Illegal instruction",
3124df6592SIngo Weinhold 	/*  5 - SIGCHLD */		"Child exited",
3224df6592SIngo Weinhold 	/*  6 - SIGABRT */		"Abort",
3324df6592SIngo Weinhold 	/*  7 - SIGPIPE */		"Broken pipe",
3424df6592SIngo Weinhold 	/*  8 - SIGFPE */		"Floating point exception",
3524df6592SIngo Weinhold 	/*  9 - SIGKILL */		"Killed (by death)",
3624df6592SIngo Weinhold 	/* 10 - SIGSTOP */		"Stopped",
3724df6592SIngo Weinhold 	/* 11 - SIGSEGV */		"Segmentation violation",
3824df6592SIngo Weinhold 	/* 12 - SIGCONT */		"Continued",
3924df6592SIngo Weinhold 	/* 13 - SIGTSTP */		"Stopped (tty output)",
4024df6592SIngo Weinhold 	/* 14 - SIGALRM */		"Alarm",
4124df6592SIngo Weinhold 	/* 15 - SIGTERM */		"Termination requested",
4224df6592SIngo Weinhold 	/* 16 - SIGTTIN */		"Stopped (tty input)",
4324df6592SIngo Weinhold 	/* 17 - SIGTTOU */		"Stopped (tty output)",
4424df6592SIngo Weinhold 	/* 18 - SIGUSR1 */		"User defined signal 1",
4524df6592SIngo Weinhold 	/* 19 - SIGUSR2 */		"User defined signal 2",
4624df6592SIngo Weinhold 	/* 20 - SIGWINCH */		"Window size changed",
4724df6592SIngo Weinhold 	/* 21 - SIGKILLTHR */	"Kill Thread",
4824df6592SIngo Weinhold 	/* 22 - SIGTRAP */		"Trace/breakpoint trap",
4924df6592SIngo Weinhold 	/* 23 - SIGPOLL */		"Pollable event",
5024df6592SIngo Weinhold 	/* 24 - SIGPROF */		"Profiling timer expired",
5124df6592SIngo Weinhold 	/* 25 - SIGSYS */		"Bad system call",
5224df6592SIngo Weinhold 	/* 26 - SIGURG */		"High bandwidth data is available at socket",
5324df6592SIngo Weinhold 	/* 27 - SIGVTALRM */	"Virtual timer expired",
5424df6592SIngo Weinhold 	/* 28 - SIGXCPU */		"CPU time limit exceeded",
5524df6592SIngo Weinhold 	/* 29 - SIGXFSZ */		"File size limit exceeded",
5624df6592SIngo Weinhold 	/* 30 - SIGBUS */		"Bus error",
5724df6592SIngo Weinhold 	/* 31 - SIGRESERVED1 */	"Reserved signal 1",
5824df6592SIngo Weinhold 	/* 32 - SIGRESERVED2 */	"Reserved signal 2",
5924df6592SIngo Weinhold 	/* 33 - realtime 1 */	"Realtime signal 1",
6024df6592SIngo Weinhold 	/* 34 - realtime 2 */	"Realtime signal 2",
6124df6592SIngo Weinhold 	/* 35 - realtime 3 */	"Realtime signal 3",
6224df6592SIngo Weinhold 	/* 36 - realtime 4 */	"Realtime signal 4",
6324df6592SIngo Weinhold 	/* 37 - realtime 5 */	"Realtime signal 5",
6424df6592SIngo Weinhold 	/* 38 - realtime 6 */	"Realtime signal 6",
6524df6592SIngo Weinhold 	/* 39 - realtime 7 */	"Realtime signal 7",
6624df6592SIngo Weinhold 	/* 40 - realtime 8 */	"Realtime signal 8",
6724df6592SIngo Weinhold 	/* 41 - invalid */		kInvalidSignalNumberText,
6824df6592SIngo Weinhold 	/* 42 - invalid */		kInvalidSignalNumberText,
6924df6592SIngo Weinhold 	/* 43 - invalid */		kInvalidSignalNumberText,
7024df6592SIngo Weinhold 	/* 44 - invalid */		kInvalidSignalNumberText,
7124df6592SIngo Weinhold 	/* 45 - invalid */		kInvalidSignalNumberText,
7224df6592SIngo Weinhold 	/* 46 - invalid */		kInvalidSignalNumberText,
7324df6592SIngo Weinhold 	/* 47 - invalid */		kInvalidSignalNumberText,
7424df6592SIngo Weinhold 	/* 48 - invalid */		kInvalidSignalNumberText,
7524df6592SIngo Weinhold 	/* 49 - invalid */		kInvalidSignalNumberText,
7624df6592SIngo Weinhold 	/* 50 - invalid */		kInvalidSignalNumberText,
7724df6592SIngo Weinhold 	/* 51 - invalid */		kInvalidSignalNumberText,
7824df6592SIngo Weinhold 	/* 52 - invalid */		kInvalidSignalNumberText,
7924df6592SIngo Weinhold 	/* 53 - invalid */		kInvalidSignalNumberText,
8024df6592SIngo Weinhold 	/* 54 - invalid */		kInvalidSignalNumberText,
8124df6592SIngo Weinhold 	/* 55 - invalid */		kInvalidSignalNumberText,
8224df6592SIngo Weinhold 	/* 56 - invalid */		kInvalidSignalNumberText,
8324df6592SIngo Weinhold 	/* 57 - invalid */		kInvalidSignalNumberText,
8424df6592SIngo Weinhold 	/* 58 - invalid */		kInvalidSignalNumberText,
8524df6592SIngo Weinhold 	/* 59 - invalid */		kInvalidSignalNumberText,
8624df6592SIngo Weinhold 	/* 60 - invalid */		kInvalidSignalNumberText,
8724df6592SIngo Weinhold 	/* 61 - invalid */		kInvalidSignalNumberText,
8824df6592SIngo Weinhold 	/* 62 - invalid */		kInvalidSignalNumberText,
8924df6592SIngo Weinhold 	/* 63 - invalid */		kInvalidSignalNumberText,
9024df6592SIngo Weinhold 	/* 64 - invalid */		kInvalidSignalNumberText
9124df6592SIngo Weinhold };
9224df6592SIngo Weinhold 
9324df6592SIngo Weinhold 
9424df6592SIngo Weinhold const char*
9524df6592SIngo Weinhold strsignal(int sig)
9624df6592SIngo Weinhold {
9724df6592SIngo Weinhold 	if (sig < 0 || sig > __MAX_SIGNO)
9824df6592SIngo Weinhold 		return kInvalidSignalNumberText;
9924df6592SIngo Weinhold 
10024df6592SIngo Weinhold 	return sys_siglist[sig];
10124df6592SIngo Weinhold }
10224df6592SIngo Weinhold 
103