summaryrefslogtreecommitdiff
path: root/libc/string/strsignal.c
blob: 83a862bfbadbb5f3fefa92e9723980726acecc7d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/* vi: set sw=4 ts=4: */
/* Copyright (C) 2000 Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
 * This file is part of the uC-Linux and is distributed under the 
 * GNU Library General Public License.
 */

#include <string.h>
#include <malloc.h>
#include <signal.h>

const char *const sys_siglist[] = {
	"Unknown signal",
	"Hangup",
	"Interrupt",
	"Quit",
	"Illegal instruction",
	"Trace/breakpoint trap",
	"IOT trap/Abort",
	"Bus error",
	"Floating point exception",
	"Killed",
	"User defined signal 1",
	"Segmentation fault",
	"User defined signal 2",
	"Broken pipe",
	"Alarm clock",
	"Terminated",
	"Stack fault",
	"Child exited",
	"Continued",
	"Stopped (signal)",
	"Stopped",
	"Stopped (tty input)",
	"Stopped (tty output)",
	"Urgent condition",
	"CPU time limit exceeded",
	"File size limit exceeded",
	"Virtual time alarm",
	"Profile signal",
	"Window size changed",
	"Possible I/O",
	"Power failure",
	"Unused signal",
	NULL
};

/********************** Function strsignal ************************************/

char *strsignal(int sig)
{
	static char retbuf[80];

	if (sys_siglist) {
		if (sig < 0 || sig >= _NSIG)
			goto unknown;
		strcpy(retbuf, sys_siglist[sig]);
		return retbuf;
	}

	if (sig <= 0)
		goto unknown;

  unknown:
	strcpy(retbuf, "Unknown Signal: ");
	strcat(retbuf, (char *) itoa(sig));
	return retbuf;
}

/********************** THE END ********************************************/