SIGACTION(p, SIGILL) = SIG_DFL; sig = sigmask(SIGILL); p->p_sigignore &= ~sig; p->p_sigcatch &= ~sig; p->p_sigmask &= ~sig; psignal(p, SIGILL); return;
free((caddr_t)kfp, M_TEMP); sigexit(p, SIGILL);
hpux_sendsig(catcher, sig, mask, code, type, val)	sig_t catcher;	int sig, mask;	u_long code;	int type;	union sigval val;{	struct proc *p = curproc;	struct hpuxsigframe *kfp, *fp;	struct frame *frame;	struct sigacts *psp = p->p_sigacts;	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;	/*	 * 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 hpuxsigframe);	if ((psp->ps_flags & SAS_ALTSTACK) && !oonstack &&	    (psp->ps_sigonstack & sigmask(sig))) {		fp = (struct hpuxsigframe *)(psp->ps_sigstk.ss_sp +		    psp->ps_sigstk.ss_size - fsize);		psp->ps_sigstk.ss_flags |= SS_ONSTACK;	} else		fp = (struct hpuxsigframe *)(frame->f_regs[SP] - fsize);	if ((unsigned)fp <= USRSTACK - ctob(p->p_vmspace->vm_ssize))		(void)uvm_grow(p, (unsigned)fp);#ifdef DEBUG	if ((hpuxsigdebug & SDB_KSTACK) && p->p_pid == hpuxsigpid)		printf("hpux_sendsig(%d): sig %d ssp %p usp %p scp %p ft %d\n",		       p->p_pid, sig, &oonstack, fp, &fp->hsf_sc, ft);#endif	kfp = (struct hpuxsigframe *)malloc((u_long)fsize, M_TEMP, M_WAITOK);	/*	 * Build the argument list for the signal handler.	 */	kfp->hsf_signum = bsdtohpuxsig(sig);	kfp->hsf_code = code;	kfp->hsf_scp = &fp->hsf_sc;	kfp->hsf_handler = catcher;	/*	 * Save necessary hardware state.  Currently this includes:	 *	- general registers	 *	- original exception frame (if not a "normal" frame)	 *	- FP coprocessor state	 */	kfp->hsf_sigstate.hss_flags = HSS_USERREGS;	bcopy((caddr_t)frame->f_regs,	    (caddr_t)kfp->hsf_sigstate.hss_frame.f_regs, sizeof frame->f_regs);	if (ft >= FMT7) {#ifdef DEBUG		if (ft > 15 || exframesize[ft] < 0)			panic("hpux_sendsig: bogus frame type");#endif		kfp->hsf_sigstate.hss_flags |= HSS_RTEFRAME;		kfp->hsf_sigstate.hss_frame.f_format = frame->f_format;		kfp->hsf_sigstate.hss_frame.f_vector = frame->f_vector;		bcopy((caddr_t)&frame->F_u,		    (caddr_t)&kfp->hsf_sigstate.hss_frame.F_u, exframesize[ft]);		/*		 * Leave an indicator that we need to clean up the kernel		 * stack.  We do this by setting the "pad word" above the		 * hardware stack frame to the amount the stack must be		 * adjusted by.		 *		 * N.B. we increment rather than just set f_stackadj in		 * case we are called from syscall when processing a		 * sigreturn.  In that case, f_stackadj may be non-zero.		 */		frame->f_stackadj += exframesize[ft];		frame->f_format = frame->f_vector = 0;#ifdef DEBUG		if (hpuxsigdebug & SDB_FOLLOW)			printf("hpux_sendsig(%d): copy out %d of frame %d\n",			       p->p_pid, exframesize[ft], ft);#endif	}	if (fputype) {		kfp->hsf_sigstate.hss_flags |= HSS_FPSTATE;		m68881_save(&kfp->hsf_sigstate.hss_fpstate);	}#ifdef DEBUG	if ((hpuxsigdebug & SDB_FPSTATE) &&	    *(char *)&kfp->hsf_sigstate.hss_fpstate)		printf("hpux_sendsig(%d): copy out FP state (%x) to %p\n",		       p->p_pid, *(u_int *)&kfp->hsf_sigstate.hss_fpstate,		       &kfp->hsf_sigstate.hss_fpstate);#endif	/*	 * Build the signal context to be used by hpux_sigreturn.	 */	kfp->hsf_sc.hsc_syscall	= 0;		/* XXX */	kfp->hsf_sc.hsc_action	= 0;		/* XXX */	kfp->hsf_sc.hsc_pad1	= kfp->hsf_sc.hsc_pad2 = 0;	kfp->hsf_sc.hsc_onstack	= oonstack;	kfp->hsf_sc.hsc_mask	= mask;	kfp->hsf_sc.hsc_sp	= frame->f_regs[SP];	kfp->hsf_sc.hsc_ps	= frame->f_sr;	kfp->hsf_sc.hsc_pc	= frame->f_pc;	/* How amazingly convenient! */	kfp->hsf_sc._hsc_pad	= 0;	kfp->hsf_sc._hsc_ap	= (int)&fp->hsf_sigstate;	if (copyout((caddr_t)kfp, (caddr_t)fp, fsize) != 0) {#ifdef DEBUG		if ((hpuxsigdebug & SDB_KSTACK) && p->p_pid == hpuxsigpid)			printf("hpux_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 (hpuxsigdebug & SDB_FOLLOW) {		printf(		  "hpux_sendsig(%d): sig %d scp %p fp %p sc_sp %x sc_ap %x\n",		   p->p_pid, sig, kfp->hsf_scp, fp,		   kfp->hsf_sc.hsc_sp, kfp->hsf_sc._hsc_ap);	}#endif	/*	 * Signal trampoline code is at base of user stack.	 */	frame->f_pc = p->p_sigcode;#ifdef DEBUG	if ((hpuxsigdebug & SDB_KSTACK) && p->p_pid == hpuxsigpid)		printf("hpux_sendsig(%d): sig %d returns\n",		       p->p_pid, sig);#endif	free((caddr_t)kfp, M_TEMP);}