ReactOS 0.4.16-dev-340-g0540c21
signal.c
Go to the documentation of this file.
1#include <precomp.h>
3
5 {
6 { SIGINT, "CTRL+C",SIG_DFL },
7 { SIGILL, "Illegal instruction",SIG_DFL },
8 { SIGFPE, "Floating-point exception",SIG_DFL },
9 { SIGSEGV, "Illegal storage access",SIG_DFL },
10 { SIGTERM, "Termination request",SIG_DFL },
11 { SIGBREAK, "CTRL+BREAK",SIG_DFL },
12 { SIGABRT, "Abnormal termination",SIG_DFL }
13 };
14
15//int nsignal = 21;
16
17/*
18 * @implemented
19 */
20//void ( *signal( int sig, void (__cdecl *func) ( int sig [, int subcode ] )) ) ( int sig );
21
22
24{
26 unsigned int i;
27
28 switch (sig)
29 {
30 case SIGINT:
31 case SIGILL:
32 case SIGFPE:
33 case SIGSEGV:
34 case SIGTERM:
35 case SIGBREAK:
36 case SIGABRT:
37 break;
38
39 default:
41 return SIG_ERR;
42 }
43
44 // check with IsBadCodePtr
45 if ( (uintptr_t)func < 4096 && func != SIG_DFL && func != SIG_IGN)
46 {
48 return SIG_ERR;
49 }
50
51 for(i=0; i < sizeof(signal_list)/sizeof(signal_list[0]); i++)
52 {
53 if ( signal_list[i].signal == sig )
54 {
57 return temp;
58 }
59 }
60
61 /* should be impossible to get here */
63 return SIG_ERR;
64}
65
66
67/*
68 * @implemented
69 */
70int
71raise(int sig)
72{
74 unsigned int i;
75
76 switch (sig)
77 {
78 case SIGINT:
79 case SIGILL:
80 case SIGFPE:
81 case SIGSEGV:
82 case SIGTERM:
83 case SIGBREAK:
84 case SIGABRT:
85 break;
86
87 default:
88 //FIXME: set last err?
89 return -1;
90 }
91
92
93 // if(sig <= 0)
94 // return -1;
95 // if(sig > SIGMAX)
96 // return -1;
97
98 for(i=0;i<sizeof(signal_list)/sizeof(signal_list[0]);i++)
99 {
100 if ( signal_list[i].signal == sig )
101 {
103 break;
104 }
105 }
106
107 if(temp == SIG_IGN)// || (sig == SIGQUIT && temp == (_p_sig_fn_t)SIG_DFL))
108 return 0; /* Ignore it */
109
110 if(temp == SIG_DFL)
111 _default_handler(sig); /* this does not return */
112 else
113 temp(sig);
114
115 return 0;
116}
117
118
119
120void _default_handler(int sig)
121{
122 _exit(3);
123}
124
125
126
127
128
void _exit(int exitcode)
Definition: _exit.c:25
#define EINVAL
Definition: acclib.h:90
int __cdecl raise(int _SigNum)
Definition: signal.c:71
#define SIG_DFL
Definition: signal.h:47
#define SIG_ERR
Definition: signal.h:52
#define SIGINT
Definition: signal.h:23
#define SIGILL
Definition: signal.h:25
void(* __p_sig_fn_t)(int)
Definition: signal.h:45
#define SIGTERM
Definition: signal.h:39
#define SIGFPE
Definition: signal.h:30
#define SIGABRT
Definition: signal.h:28
#define SIG_IGN
Definition: signal.h:48
#define SIGSEGV
Definition: signal.h:33
#define SIGBREAK
Definition: signal.h:40
GLenum func
Definition: glext.h:6028
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
unsigned int uintptr_t
Definition: intrin.h:47
static calc_node_t temp
Definition: rpn_ieee.c:38
errno_t __cdecl _set_errno(_In_ int _Value)
static sig_element signal_list[]
Definition: signal.c:4
void _default_handler(int sig)
Definition: signal.c:120
int signal
Definition: except.c:84
__p_sig_fn_t handler
Definition: msvcrt.h:148