#include #include #include #include #include void _default_handler(int signal); typedef struct _sig_element { int signal; char *signame; _p_sig_fn_t handler; } sig_element; static sig_element signal_list[SIGMAX] = { { 0, "Signal 0", SIG_DFL }, { SIGABRT, "Aborted",SIG_DFL }, { SIGFPE, "Erroneous arithmetic operation",SIG_DFL }, { SIGILL, "Illegal instruction",SIG_DFL }, { SIGINT, "Interrupt",SIG_DFL }, { SIGSEGV, "Invalid access to storage",SIG_DFL }, { SIGTERM, "Terminated",SIG_DFL }, { SIGHUP, "Hangup",SIG_DFL }, { SIGQUIT, "Quit",SIG_DFL }, { SIGPIPE, "Broken pipe",SIG_DFL }, { SIGKILL, "Killed",SIG_DFL }, { SIGALRM, "Alarm clock",SIG_DFL }, { 0, "Stopped (signal)",SIG_DFL }, { 0, "Stopped",SIG_DFL }, { 0, "Continued",SIG_DFL }, { 0, "Child exited",SIG_DFL }, { 0, "Stopped (tty input)",SIG_DFL }, { 0, "Stopped (tty output)",SIG_DFL }, { 0, NULL, SIG_DFL } }; int nsignal = 21; _p_sig_fn_t signal(int sig, _p_sig_fn_t func) { _p_sig_fn_t temp; int i; if(sig <= 0 || sig > SIGMAX || sig == SIGKILL) { __set_errno(EINVAL); return SIG_ERR; } // check with IsBadCodePtr if ( func < (_p_sig_fn_t)4096 ) { __set_errno(EINVAL); return SIG_ERR; } for(i=0;i SIGMAX) return -1; for(i=0;i