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