SIGACTION(p, sig) = SIG_DFL; p->p_sigignore &= ~sig; p->p_sigcatch &= ~sig; p->p_sigmask &= ~sig; psignal(p, sig); return;
sigexit(p, sig);
sunos_sendsig(catcher, sig, mask, code, type, val)	sig_t catcher;	int sig, mask;	u_long code;	int type;	union sigval val;{	register struct proc *p = curproc;	register struct sunos_sigframe *fp;	struct sunos_sigframe kfp;	register struct frame *frame;	register struct sigacts *psp = p->p_sigacts;	register short ft;	int oonstack, fsize;	frame = (struct frame *)p->p_md.md_regs;	ft = frame->f_format;	oonstack = psp->ps_sigstk.ss_flags & SS_ONSTACK;	/*	 * if this is a hardware fault (ft >= FMT9), sunos_sendsig	 * can't currently handle it. Reset signal actions and	 * have the process die unconditionally. 	 */	if (ft >= FMT9) {		SIGACTION(p, sig) = SIG_DFL;		p->p_sigignore &= ~sig;		p->p_sigcatch &= ~sig;		p->p_sigmask &= ~sig;		psignal(p, sig);		return;	}	/*	 * Allocate and validate space for the signal handler	 * context. Note that if the stack is in P0 space, the	 * call to grow() is a nop, and the useracc() check	 * will fail if the process has not already allocated	 * the space with a `brk'.	 */	fsize = sizeof(struct sunos_sigframe);	if ((psp->ps_flags & SAS_ALTSTACK) && oonstack == 0 &&	    (psp->ps_sigonstack & sigmask(sig))) {		fp = (struct sunos_sigframe *)(psp->ps_sigstk.ss_sp +		    psp->ps_sigstk.ss_size - sizeof(struct sunos_sigframe));		psp->ps_sigstk.ss_flags |= SS_ONSTACK;	} else		fp = (struct sunos_sigframe *)frame->f_regs[SP] - 1;	if ((vaddr_t)fp <= USRSTACK - ctob(p->p_vmspace->vm_ssize)) 		(void)uvm_grow(p, (unsigned)fp);#ifdef DEBUG	if ((sigdebug & SDB_KSTACK) && p->p_pid == sigpid)		printf("sunos_sendsig(%d): sig %d ssp %p usp %p scp %p ft %d\n",		       p->p_pid, sig, &oonstack, fp, &fp->sf_sc, ft);#endif	/* 	 * Build the argument list for the signal handler.	 */	kfp.sf_signum = sig;	kfp.sf_code = code;	kfp.sf_scp = &fp->sf_sc;	kfp.sf_addr = (u_int)val.sival_ptr;	/*	 * Build the signal context to be used by sigreturn.	 */	kfp.sf_sc.sc_onstack = oonstack;	kfp.sf_sc.sc_mask = mask;	kfp.sf_sc.sc_sp = frame->f_regs[SP];	kfp.sf_sc.sc_pc = frame->f_pc;	kfp.sf_sc.sc_ps = frame->f_sr;	if (copyout(&kfp, fp, fsize) != 0) {#ifdef DEBUG		if ((sigdebug & SDB_KSTACK) && p->p_pid == sigpid)			printf("sunos_sendsig(%d): copyout failed on sig %d\n",			       p->p_pid, sig);#endif		/*		 * Process has trashed its stack; give it an illegal		 * instruction to halt it in its tracks.		 */		SIGACTION(p, SIGILL) = SIG_DFL;		sig = sigmask(SIGILL);		p->p_sigignore &= ~sig;		p->p_sigcatch &= ~sig;		p->p_sigmask &= ~sig;		psignal(p, SIGILL);		return;	}	frame->f_regs[SP] = (int)fp;#ifdef DEBUG	if (sigdebug & SDB_FOLLOW)		printf("sunos_sendsig(%d): sig %d scp %p sc_sp %x\n",		       p->p_pid, sig, &fp->sf_sc,kfp.sf_sc.sc_sp);#endif	/* have the user-level trampoline code sort out what registers it	   has to preserve. */	frame->f_pc = (u_int) catcher;#ifdef DEBUG	if ((sigdebug & SDB_KSTACK) && p->p_pid == sigpid)		printf("sunos_sendsig(%d): sig %d returns\n",		       p->p_pid, sig);#endif}