From d41554e6b486a0a50f23720869582f0b1fae3f6f Mon Sep 17 00:00:00 2001 From: John Hodge Date: Sun, 8 Sep 2013 22:28:26 +0800 Subject: [PATCH] Kernel - Added default actions to most signals --- KernelLand/Kernel/threads.c | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/KernelLand/Kernel/threads.c b/KernelLand/Kernel/threads.c index 50889bff..280f7f28 100644 --- a/KernelLand/Kernel/threads.c +++ b/KernelLand/Kernel/threads.c @@ -1116,22 +1116,41 @@ void Threads_SetSignalHandler(int SignalNum, void *Handler) } /** - * \return 0 Ignore + * \brief Gets the registered (or default, if none set) handler for a signal. + * \return Handler function pointer, OR NULL if no signal to be ignored */ void *Threads_GetSignalHandler(int SignalNum) { + // TODO: Core dump + void *User_Signal_Core = User_Signal_Kill; + if( SignalNum <= 0 || SignalNum >= NSIGNALS ) return NULL; void *ret = Proc_GetCurThread()->Process->SignalHandlers[SignalNum]; - if( !ret ) + if( !ret || (SignalNum == SIGKILL || SignalNum == SIGSTOP) ) { // Defaults switch(SignalNum) { + case SIGHUP: case SIGINT: + ret = User_Signal_Kill; + break; + case SIGQUIT: + case SIGILL: + case SIGABRT: + case SIGFPE: + ret = User_Signal_Core; + break; case SIGKILL: + ret = User_Signal_Kill; + break; case SIGSEGV: - case SIGHUP: + ret = User_Signal_Core; + break; + case SIGPIPE: + case SIGALRM: + case SIGTERM: ret = User_Signal_Kill; break; default: -- 2.20.1