aboutsummaryrefslogtreecommitdiff
path: root/sys/kern/kern_sig.c
diff options
context:
space:
mode:
authorMartin Cracauer <cracauer@FreeBSD.org>1999-07-06 07:13:48 +0000
committerMartin Cracauer <cracauer@FreeBSD.org>1999-07-06 07:13:48 +0000
commitaff66c545566ee314ca422b609bb70850c8185cb (patch)
tree14bfca59deabfb689740ff3b37f13de6d1b1453e /sys/kern/kern_sig.c
parent8f437f4439f5530c30321486780ea2d11d9e953b (diff)
downloadsrc-aff66c545566ee314ca422b609bb70850c8185cb.tar.gz
src-aff66c545566ee314ca422b609bb70850c8185cb.zip
Implement SA_SIGINFO for i386. Thanks to Bruce Evans for much more
than a review, this was a nice puzzle. This is supposed to be binary and source compatible with older applications that access the old FreeBSD-style three arguments to a signal handler. Except those applications that access hidden signal handler arguments bejond the documented third one. If you have applications that do, please let me know so that we take the opportunity to provide the functionality they need in a documented manner. Also except application that use 'struct sigframe' directly. You need to recompile gdb and doscmd. `make world` is recommended. Example program that demonstrates how SA_SIGINFO and old-style FreeBSD handlers (with their three args) may be used in the same process is at http://www3.cons.org/tmp/fbsd-siginfo.c Programs that use the old FreeBSD-style three arguments are easy to change to SA_SIGINFO (although they don't need to, since the old style will still work): Old args to signal handler: void handler_sn(int sig, int code, struct sigcontext *scp) New args: void handler_si(int sig, siginfo_t *si, void *third) where: old:code == new:second->si_code old:scp == &(new:si->si_scp) /* Passed by value! */ The latter is also pointed to by new:third, but accessing via si->si_scp is preferred because it is type-save. FreeBSD implementation notes: - This is just the framework to make the interface POSIX compatible. For now, no additional functionality is provided. This is supposed to happen now, starting with floating point values. - We don't use 'sigcontext_t.si_value' for now (POSIX meant it for realtime-related values). - Documentation will be updated when new functionality is added and the exact arguments passed are determined. The comments in sys/signal.h are meant to be useful. Reviewed by: BDE
Notes
Notes: svn path=/head/; revision=48621
Diffstat (limited to 'sys/kern/kern_sig.c')
-rw-r--r--sys/kern/kern_sig.c30
1 files changed, 22 insertions, 8 deletions
diff --git a/sys/kern/kern_sig.c b/sys/kern/kern_sig.c
index 78f5d50d3169..2e63a0a927af 100644
--- a/sys/kern/kern_sig.c
+++ b/sys/kern/kern_sig.c
@@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)kern_sig.c 8.7 (Berkeley) 4/18/94
- * $Id: kern_sig.c,v 1.55 1999/04/28 11:36:59 phk Exp $
+ * $Id: kern_sig.c,v 1.56 1999/05/03 23:57:22 billf Exp $
*/
#include "opt_compat.h"
@@ -126,9 +126,13 @@ sigaction(p, uap)
return (EINVAL);
sa = &vec;
if (uap->osa) {
- sa->sa_handler = ps->ps_sigact[signum];
- sa->sa_mask = ps->ps_catchmask[signum];
bit = sigmask(signum);
+ if ((ps->ps_siginfo & bit) != 0)
+ sa->sa_sigaction =
+ (__siginfohandler_t *)ps->ps_sigact[signum];
+ else
+ sa->sa_handler = ps->ps_sigact[signum];
+ sa->sa_mask = ps->ps_catchmask[signum];
sa->sa_flags = 0;
if ((ps->ps_sigonstack & bit) != 0)
sa->sa_flags |= SA_ONSTACK;
@@ -138,6 +142,8 @@ sigaction(p, uap)
sa->sa_flags |= SA_RESETHAND;
if ((ps->ps_signodefer & bit) != 0)
sa->sa_flags |= SA_NODEFER;
+ if ((ps->ps_siginfo & bit) != 0)
+ sa->sa_flags |= SA_SIGINFO;
if (signum == SIGCHLD && p->p_procsig->ps_flag & P_NOCLDSTOP)
sa->sa_flags |= SA_NOCLDSTOP;
if (signum == SIGCHLD && p->p_procsig->ps_flag & P_NOCLDWAIT)
@@ -151,7 +157,7 @@ sigaction(p, uap)
sizeof (vec))))
return (error);
if ((signum == SIGKILL || signum == SIGSTOP) &&
- sa->sa_handler != SIG_DFL)
+ ps->ps_sigact[signum] != SIG_DFL)
return (EINVAL);
setsigvec(p, signum, sa);
}
@@ -172,8 +178,14 @@ setsigvec(p, signum, sa)
* Change setting atomically.
*/
(void) splhigh();
- ps->ps_sigact[signum] = sa->sa_handler;
ps->ps_catchmask[signum] = sa->sa_mask &~ sigcantmask;
+ if (sa->sa_flags & SA_SIGINFO) {
+ ps->ps_sigact[signum] = sa->sa_handler;
+ ps->ps_siginfo |= bit;
+ } else {
+ ps->ps_sigact[signum] = (__sighandler_t *)sa->sa_sigaction;
+ ps->ps_siginfo &= ~bit;
+ }
if ((sa->sa_flags & SA_RESTART) == 0)
ps->ps_sigintr |= bit;
else
@@ -221,15 +233,15 @@ setsigvec(p, signum, sa)
* However, don't put SIGCONT in p_sigignore,
* as we have to restart the process.
*/
- if (sa->sa_handler == SIG_IGN ||
- (sigprop[signum] & SA_IGNORE && sa->sa_handler == SIG_DFL)) {
+ if (ps->ps_sigact[signum] == SIG_IGN ||
+ (sigprop[signum] & SA_IGNORE && ps->ps_sigact[signum] == SIG_DFL)) {
p->p_siglist &= ~bit; /* never to be seen again */
if (signum != SIGCONT)
p->p_sigignore |= bit; /* easier in psignal */
p->p_sigcatch &= ~bit;
} else {
p->p_sigignore &= ~bit;
- if (sa->sa_handler == SIG_DFL)
+ if (ps->ps_sigact[signum] == SIG_DFL)
p->p_sigcatch &= ~bit;
else
p->p_sigcatch |= bit;
@@ -387,6 +399,8 @@ osigvec(p, uap)
sv->sv_flags |= SV_RESETHAND;
if ((ps->ps_signodefer & bit) != 0)
sv->sv_flags |= SV_NODEFER;
+ if ((ps->ps_siginfo & bit) != 0)
+ sv->sv_flags |= SV_SIGINFO;
#ifndef COMPAT_SUNOS
if (signum == SIGCHLD && p->p_procsig->ps_flag & P_NOCLDSTOP)
sv->sv_flags |= SV_NOCLDSTOP;