Kill processes which ignore signals thatshould not be ignored

This commit is contained in:
Erik van der Kouwe
2010-01-31 19:13:20 +00:00
parent 82ce09234b
commit 310876dcec
5 changed files with 33 additions and 16 deletions
+1
View File
@@ -21,6 +21,7 @@ EXTERN int call_nr; /* system call number */
extern _PROTOTYPE (int (*call_vec[]), (void) ); /* system call handlers */
EXTERN sigset_t core_sset; /* which signals cause core images */
EXTERN sigset_t ign_sset; /* which signals are by default ignored */
EXTERN sigset_t noign_sset; /* which signals cannot be ignored */
EXTERN u32_t system_hz; /* System clock frequency. */
EXTERN int abort_flag;
+5
View File
@@ -200,6 +200,8 @@ PRIVATE int sef_cb_init_fresh(int type, sef_init_info_t *info)
SIGEMT, SIGFPE, SIGBUS, SIGSEGV };
static char ign_sigs[] = { SIGCHLD, SIGWINCH, SIGCONT };
static char mess_sigs[] = { SIGTERM, SIGHUP, SIGABRT, SIGQUIT };
static char noign_sigs[] = { SIGILL, SIGTRAP, SIGEMT, SIGFPE,
SIGBUS, SIGSEGV };
register struct mproc *rmp;
register char *sig_ptr;
message mess;
@@ -218,6 +220,9 @@ PRIVATE int sef_cb_init_fresh(int type, sef_init_info_t *info)
sigemptyset(&ign_sset);
for (sig_ptr = ign_sigs; sig_ptr < ign_sigs+sizeof(ign_sigs); sig_ptr++)
sigaddset(&ign_sset, *sig_ptr);
sigemptyset(&noign_sset);
for (sig_ptr = noign_sigs; sig_ptr < noign_sigs+sizeof(noign_sigs); sig_ptr++)
sigaddset(&noign_sset, *sig_ptr);
/* Obtain a copy of the boot monitor parameters and the kernel info struct.
* Parse the list of free memory chunks. This list is what the boot monitor
+12 -6
View File
@@ -351,7 +351,7 @@ int trace; /* pass signal to tracer first? */
* context from the sigcontext structure.
* If there is insufficient stack space, kill the process.
*/
int r, slot;
int r, slot, badignore;
slot = (int) (rmp - mproc);
if ((rmp->mp_flags & (IN_USE | EXITING)) != IN_USE) {
@@ -387,16 +387,22 @@ int trace; /* pass signal to tracer first? */
return;
}
if (sigismember(&rmp->mp_ignore, signo)) {
/* some signals cannot be safely ignored */
badignore = sigismember(&noign_sset, signo) && (
sigismember(&rmp->mp_ignore, signo) ||
sigismember(&rmp->mp_sigmask, signo) ||
sigismember(&rmp->mp_sig2mess, signo));
if (!badignore && sigismember(&rmp->mp_ignore, signo)) {
/* Signal should be ignored. */
return;
}
if (sigismember(&rmp->mp_sigmask, signo)) {
if (!badignore && sigismember(&rmp->mp_sigmask, signo)) {
/* Signal should be blocked. */
sigaddset(&rmp->mp_sigpending, signo);
return;
}
if (sigismember(&rmp->mp_sig2mess, signo)) {
if (!badignore && sigismember(&rmp->mp_sig2mess, signo)) {
/* Mark event pending in process slot and send notification. */
sigaddset(&rmp->mp_sigpending, signo);
notify(rmp->mp_endpoint);
@@ -412,7 +418,7 @@ int trace; /* pass signal to tracer first? */
return;
}
if (sigismember(&rmp->mp_catch, signo)) {
if (!badignore && sigismember(&rmp->mp_catch, signo)) {
/* Signal is caught. First interrupt the process's current call, if
* applicable. This may involve a roundtrip to FS, in which case we'll
* have to check back later.
@@ -436,7 +442,7 @@ int trace; /* pass signal to tracer first? */
/* We were unable to spawn a signal handler. Kill the process. */
}
else if (sigismember(&ign_sset, signo)) {
else if (!badignore && sigismember(&ign_sset, signo)) {
/* Signal defaults to being ignored. */
return;
}