+ * Send a signal caused by a trap to the current process.
+ * If it will be caught immediately, deliver it with correct code.
+ * Otherwise, post it normally.
+ */
+void
+trapsignal(p, sig, code)
+ struct proc *p;
+ register int sig;
+ unsigned code;
+{
+ register struct sigacts *ps = p->p_sigacts;
+ int mask;
+
+ mask = sigmask(sig);
+ if ((p->p_flag & STRC) == 0 && (p->p_sigcatch & mask) != 0 &&
+ (p->p_sigmask & mask) == 0) {
+ p->p_stats->p_ru.ru_nsignals++;
+#ifdef KTRACE
+ if (KTRPOINT(p, KTR_PSIG))
+ ktrpsig(p->p_tracep, sig, ps->ps_sigact[sig],
+ p->p_sigmask, code);
+#endif
+#if defined(i386)
+ sendsig(ps->ps_sigact[sig], sig, p->p_sigmask, code, 0x100);
+#else
+ sendsig(ps->ps_sigact[sig], sig, p->p_sigmask, code);
+#endif
+ p->p_sigmask |= ps->ps_catchmask[sig] | mask;
+ } else {
+ ps->ps_code = code; /* XXX for core dump/debugger */
+ psignal(p, sig);
+ }
+}
+
+/*
+ * Send the specified signal to the specified process.
+ * If the signal has an action, the action is usually performed
+ * by the target process rather than the caller; we simply add
+ * the signal to the set of pending signals for the process.
+ * Exceptions:
+ * o When a stop signal is sent to a sleeping process that takes the default
+ * action, the process is stopped without awakening it.
+ * o SIGCONT restarts stopped processes (or puts them back to sleep)
+ * regardless of the signal action (eg, blocked or ignored).
+ * Other ignored signals are discarded immediately.