81a1c4ee18068d995c38538a57bacdb81592f984
7 #include <internal/file.h>
9 void _default_handler(int signal
);
11 //typedef void (*_p_sig_fn_t)(int);
14 typedef struct _sig_element
23 static sig_element signal_list
[] =
25 { SIGINT
, "CTRL+C",SIG_DFL
},
26 { SIGILL
, "Illegal instruction",SIG_DFL
},
27 { SIGFPE
, "Floating-point exception",SIG_DFL
},
28 { SIGSEGV
, "Illegal storage access",SIG_DFL
},
29 { SIGTERM
, "Termination request",SIG_DFL
},
30 { SIGBREAK
, "CTRL+BREAK",SIG_DFL
},
31 { SIGABRT
, "Abnormal termination",SIG_DFL
}
39 //void ( *signal( int sig, void (__cdecl *func) ( int sig [, int subcode ] )) ) ( int sig );
44 __p_sig_fn_t
signal(int sig
, __p_sig_fn_t func
)
65 // check with IsBadCodePtr
66 if ( func
< (__p_sig_fn_t
)4096 && func
!= SIG_DFL
&& func
!= SIG_IGN
)
72 for(i
=0; i
< sizeof(signal_list
)/sizeof(signal_list
[0]); i
++)
74 if ( signal_list
[i
].signal
== sig
)
76 temp
= signal_list
[i
].handler
;
77 signal_list
[i
].handler
= func
;
82 /* should be impossible to get here */
94 __p_sig_fn_t temp
= 0;
109 //FIXME: set last err?
119 for(i
=0;i
<sizeof(signal_list
)/sizeof(signal_list
[0]);i
++)
121 if ( signal_list
[i
].signal
== sig
)
123 temp
= signal_list
[i
].handler
;
128 if(temp
== SIG_IGN
)// || (sig == SIGQUIT && temp == (_p_sig_fn_t)SIG_DFL))
129 return 0; /* Ignore it */
132 _default_handler(sig
); /* this does not return */
141 void _default_handler(int sig
)