From 31fca52a1000895b705169409d67ab1083ee7418 Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Sat, 3 Jan 2015 22:20:04 +0000 Subject: [PATCH] signals: cleanup chksig a little, clear mask on ignored no-op signals --- Kernel/process.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/Kernel/process.c b/Kernel/process.c index 8d8dcd3e..2ca0349b 100644 --- a/Kernel/process.c +++ b/Kernel/process.c @@ -432,35 +432,38 @@ void sgrpsig(uint16_t pgrp, uint16_t sig) void chksigs(void) { uint8_t j; + uint32_t pending = udata.u_ptab->p_pending & ~udata.u_ptab->p_held; + int16_t (**svec)() = &udata.u_sigvec[0]; + uint32_t m; // any signals pending? - if (!(udata.u_ptab->p_pending & ~udata.u_ptab->p_held)) { + if (!pending) return; - } + // dispatch the lowest numbered signal for (j = 1; j < NSIGS; ++j) { - if (! - (sigmask(j) & udata.u_ptab->p_pending & ~udata.u_ptab-> - p_held)) + svec++; + m = sigmask(j); + if (!(m & pending)) continue; /* This is more complex than in V7 - we have multiple behaviours (plus the unimplemented as yet core dump) */ - if (udata.u_sigvec[j] == SIG_DFL) { + if (*svec == SIG_DFL) { /* SIGCONT is subtle - we woke the process to handle the signal so ignoring here works fine */ if (j == SIGCHLD || j == SIGURG || - j == SIGIO || j == SIGCONT) + j == SIGIO || j == SIGCONT) { + udata.u_ptab->p_pending &= ~m; // unset the bit continue; + } /* FIXME: core dump on some signals */ #ifdef DEBUG kputs("process terminated by signal: "); #endif doexit(0, j); - } - - if (udata.u_sigvec[j] != SIG_IGN) { + } else if (*svec != SIG_IGN) { /* Arrange to call the user routine at return */ - udata.u_ptab->p_pending &= ~sigmask(j); // unset the bit + udata.u_ptab->p_pending &= ~m; // unset the bit #ifdef DEBUG kprintf("about to process signal %d\n", j); #endif -- 2.34.1