summaryrefslogtreecommitdiff
path: root/sys/kern/kern_sig.c
diff options
context:
space:
mode:
authorMichael Shalayeff <mickey@cvs.openbsd.org>2004-04-06 17:24:13 +0000
committerMichael Shalayeff <mickey@cvs.openbsd.org>2004-04-06 17:24:13 +0000
commitb189424003dc4748c4b91eaebb25d2b6819ce692 (patch)
tree0b1f5fd540c1356a9a4bb215ebbade3062e15614 /sys/kern/kern_sig.c
parent64f3ff56324a32070293526a8aee276282c34211 (diff)
fix siginfo generation for posted signals and avoid double ktrpsig() call for the same signal; deraadt@ ok
Diffstat (limited to 'sys/kern/kern_sig.c')
-rw-r--r--sys/kern/kern_sig.c45
1 files changed, 28 insertions, 17 deletions
diff --git a/sys/kern/kern_sig.c b/sys/kern/kern_sig.c
index 236cc828960..494f6878d80 100644
--- a/sys/kern/kern_sig.c
+++ b/sys/kern/kern_sig.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_sig.c,v 1.69 2004/01/14 05:23:25 tedu Exp $ */
+/* $OpenBSD: kern_sig.c,v 1.70 2004/04/06 17:24:11 mickey Exp $ */
/* $NetBSD: kern_sig.c,v 1.54 1996/04/22 01:38:32 christos Exp $ */
/*
@@ -762,18 +762,18 @@ trapsignal(p, signum, code, type, sigval)
register struct sigacts *ps = p->p_sigacts;
int mask;
-#ifdef KTRACE
- if (KTRPOINT(p, KTR_PSIG)) {
- siginfo_t si;
-
- initsiginfo(&si, signum, code, type, sigval);
- ktrpsig(p, signum, ps->ps_sigact[signum],
- p->p_sigmask, code, &si);
- }
-#endif
mask = sigmask(signum);
if ((p->p_flag & P_TRACED) == 0 && (p->p_sigcatch & mask) != 0 &&
(p->p_sigmask & mask) == 0) {
+#ifdef KTRACE
+ if (KTRPOINT(p, KTR_PSIG)) {
+ siginfo_t si;
+
+ initsiginfo(&si, signum, code, type, sigval);
+ ktrpsig(p, signum, ps->ps_sigact[signum],
+ p->p_sigmask, type, &si);
+ }
+#endif
p->p_stats->p_ru.ru_nsignals++;
(*p->p_emul->e_sendsig)(ps->ps_sigact[signum], signum,
p->p_sigmask, code, type, sigval);
@@ -785,7 +785,10 @@ trapsignal(p, signum, code, type, sigval)
ps->ps_sigact[signum] = SIG_DFL;
}
} else {
+ ps->ps_sig = signum;
ps->ps_code = code; /* XXX for core dump/debugger */
+ ps->ps_type = type;
+ ps->ps_sigval = sigval;
psignal(p, signum);
}
}
@@ -1195,8 +1198,8 @@ postsig(signum)
sig_t action;
u_long code;
int mask, returnmask;
- union sigval null_sigval;
- int s;
+ union sigval sigval;
+ int s, type;
#ifdef DIAGNOSTIC
if (signum == 0)
@@ -1205,21 +1208,26 @@ postsig(signum)
mask = sigmask(signum);
p->p_siglist &= ~mask;
action = ps->ps_sigact[signum];
+ sigval.sival_ptr = 0;
+ type = SI_USER;
if (ps->ps_sig != signum) {
code = 0;
+ type = SI_USER;
+ sigval.sival_ptr = 0;
} else {
code = ps->ps_code;
+ type = ps->ps_type;
+ sigval = ps->ps_sigval;
}
#ifdef KTRACE
if (KTRPOINT(p, KTR_PSIG)) {
siginfo_t si;
- null_sigval.sival_ptr = 0;
- initsiginfo(&si, signum, 0, SI_USER, null_sigval);
+ initsiginfo(&si, signum, code, type, sigval);
ktrpsig(p, signum, action, ps->ps_flags & SAS_OLDMASK ?
- ps->ps_oldmask : p->p_sigmask, code, &si);
+ ps->ps_oldmask : p->p_sigmask, type, &si);
}
#endif
if (action == SIG_DFL) {
@@ -1262,11 +1270,14 @@ postsig(signum)
splx(s);
p->p_stats->p_ru.ru_nsignals++;
if (ps->ps_sig == signum) {
+ ps->ps_sig = 0;
ps->ps_code = 0;
+ ps->ps_type = SI_USER;
+ ps->ps_sigval.sival_ptr = NULL;
}
- null_sigval.sival_ptr = 0;
+
(*p->p_emul->e_sendsig)(action, signum, returnmask, code,
- SI_USER, null_sigval);
+ type, sigval);
}
}