xref: /netbsd-src/lib/libc/gen/signalname.c (revision 486691905e31cfc9fc758bbcf97cec7cd1d78102)
1*48669190Skre /* $NetBSD: signalname.c,v 1.1 2017/05/09 11:14:16 kre Exp $ */
2*48669190Skre 
3*48669190Skre /*
4*48669190Skre  * Software available to all and sundry without limitations
5*48669190Skre  * but without warranty of fitness for any purpose whatever.
6*48669190Skre  *
7*48669190Skre  * Licensed for any use, including redistribution in source
8*48669190Skre  * and binary forms, with or without modifications, subject
9*48669190Skre  * the following agreement:
10*48669190Skre  *
11*48669190Skre  * Licensee agrees to indemnify licensor, and distributor, for
12*48669190Skre  * the full amount of any any claim made by the licensee against
13*48669190Skre  * the licensor or distributor, for any action that results from
14*48669190Skre  * any use or redistribution of this software, plus any costs
15*48669190Skre  * incurred by licensor or distributor resulting from that claim.
16*48669190Skre  *
17*48669190Skre  * This licence must be retained with the software.
18*48669190Skre  */
19*48669190Skre 
20*48669190Skre #include <sys/types.h>
21*48669190Skre 
22*48669190Skre #include <signal.h>
23*48669190Skre #include <string.h>
24*48669190Skre 
25*48669190Skre /*
26*48669190Skre  * signalname()
27*48669190Skre  *
28*48669190Skre  *	Converts the signal number "sig" to its
29*48669190Skre  *	signal name (without the "SIG" prefix).
30*48669190Skre  *
31*48669190Skre  * Returns:
32*48669190Skre  *	NULL on error (invalid signal number)
33*48669190Skre  *	otherwise the (abbreviated) signal name (no "SIG").
34*48669190Skre  */
35*48669190Skre 
36*48669190Skre const char *
signalname(int sig)37*48669190Skre signalname(int sig)
38*48669190Skre {
39*48669190Skre 
40*48669190Skre 	if (sig <= 0 || sig >= NSIG)
41*48669190Skre 		return NULL;
42*48669190Skre 
43*48669190Skre 	return sys_signame[sig];
44*48669190Skre }
45