Implement SA_NODEFER sa_flag for sigaction():

Add SA_NODEFER define to signal.h
	Add ps_nodefer field to struct sigacts in signalvar.h.
	Add code to kern_sig.c to handle SA_NODEFER.

If flag is set, when the signal is delivered, it is not masked automatically
from receiving the same signal again.

Reviewed by:	 wollman, bde
This commit is contained in:
swallace 1995-10-19 19:16:01 +00:00
parent f68a41fc52
commit f62e0784cb
4 changed files with 18 additions and 6 deletions

View File

@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)kern_sig.c 8.7 (Berkeley) 4/18/94
* $Id: kern_sig.c,v 1.10 1995/03/16 18:12:35 bde Exp $
* $Id: kern_sig.c,v 1.11 1995/05/30 08:05:40 rgrimes Exp $
*/
#define SIGPROP /* include signal properties table */
@ -109,6 +109,8 @@ sigaction(p, uap, retval)
sa->sa_flags |= SA_ONSTACK;
if ((ps->ps_sigintr & bit) == 0)
sa->sa_flags |= SA_RESTART;
if ((ps->ps_nodefer & bit) != 0)
sa->sa_flags |= SA_NODEFER;
if (p->p_flag & P_NOCLDSTOP)
sa->sa_flags |= SA_NOCLDSTOP;
if ((error = copyout((caddr_t)sa, (caddr_t)uap->osa,
@ -148,6 +150,10 @@ setsigvec(p, signum, sa)
ps->ps_sigonstack |= bit;
else
ps->ps_sigonstack &= ~bit;
if (sa->sa_flags & SA_NODEFER)
ps->ps_nodefer |= bit;
else
ps->ps_nodefer &= ~bit;
#ifdef COMPAT_SUNOS
if (sa->sa_flags & SA_USERTRAMP)
ps->ps_usertramp |= bit;
@ -654,7 +660,9 @@ trapsignal(p, signum, code)
p->p_sigmask, code);
#endif
sendsig(ps->ps_sigact[signum], signum, p->p_sigmask, code);
p->p_sigmask |= ps->ps_catchmask[signum] | mask;
p->p_sigmask |= ps->ps_catchmask[signum];
p->p_sigmask |= ps->ps_catchmask[signum] |
(mask & ~ps->ps_nodefer);
} else {
ps->ps_code = code; /* XXX for core dump/debugger */
psignal(p, signum);
@ -1088,7 +1096,8 @@ postsig(signum)
ps->ps_flags &= ~SAS_OLDMASK;
} else
returnmask = p->p_sigmask;
p->p_sigmask |= ps->ps_catchmask[signum] | mask;
p->p_sigmask |= ps->ps_catchmask[signum] |
(mask & ~ps->ps_nodefer);
(void) spl0();
p->p_stats->p_ru.ru_nsignals++;
if (ps->ps_sig != signum) {

View File

@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)signal.h 8.2 (Berkeley) 1/21/94
* $Id: signal.h,v 1.3 1995/01/29 01:19:25 ats Exp $
* $Id: signal.h,v 1.4 1995/06/28 02:14:04 bde Exp $
*/
#ifndef _SYS_SIGNAL_H_
@ -136,6 +136,7 @@ struct sigaction {
#endif
#endif
#define SA_NOCLDSTOP 0x0008 /* do not generate SIGCHLD on child stop */
#define SA_NODEFER 0x0010 /* don't mask the signal we're delivering */
/*
* Flags for sigprocmask:

View File

@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)signal.h 8.2 (Berkeley) 1/21/94
* $Id: signal.h,v 1.3 1995/01/29 01:19:25 ats Exp $
* $Id: signal.h,v 1.4 1995/06/28 02:14:04 bde Exp $
*/
#ifndef _SYS_SIGNAL_H_
@ -136,6 +136,7 @@ struct sigaction {
#endif
#endif
#define SA_NOCLDSTOP 0x0008 /* do not generate SIGCHLD on child stop */
#define SA_NODEFER 0x0010 /* don't mask the signal we're delivering */
/*
* Flags for sigprocmask:

View File

@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)signalvar.h 8.3 (Berkeley) 1/4/94
* $Id: signalvar.h,v 1.4 1994/10/02 17:24:55 phk Exp $
* $Id: signalvar.h,v 1.5 1995/03/16 18:16:24 bde Exp $
*/
#ifndef _SYS_SIGNALVAR_H_ /* tmp for user.h */
@ -58,6 +58,7 @@ struct sigacts {
int ps_code; /* for core dump/debugger XXX */
int ps_addr; /* for core dump/debugger XXX */
sigset_t ps_usertramp; /* SunOS compat; libc sigtramp XXX */
sigset_t ps_nodefer; /* signals not to defer */
};
/* signal flags */