-/* $OpenBSD: kern_sig.c,v 1.273 2021/02/15 09:35:59 mpi Exp $ */
+/* $OpenBSD: kern_sig.c,v 1.274 2021/03/04 09:02:37 mpi Exp $ */
/* $NetBSD: kern_sig.c,v 1.54 1996/04/22 01:38:32 christos Exp $ */
/*
goto out;
/*
* Process is sleeping and traced... make it runnable
- * so it can discover the signal in issignal() and stop
+ * so it can discover the signal in cursig() and stop
* for the parent.
*/
if (pr->ps_flags & PS_TRACED)
}
/*
+ * Determine signal that should be delivered to process p, the current
+ * process, 0 if none.
+ *
* If the current process has received a signal (should be caught or cause
* termination, should interrupt current syscall), return the signal number.
* Stop signals with default action are processed immediately, then cleared;
* they aren't returned. This is checked after each entry to the system for
- * a syscall or trap (though this can usually be done without calling issignal
- * by checking the pending signal masks in the CURSIG macro.) The normal call
- * sequence is
+ * a syscall or trap. The normal call sequence is
*
- * while (signum = CURSIG(curproc))
+ * while (signum = cursig(curproc))
* postsig(signum);
*
* Assumes that if the P_SINTR flag is set, we're holding both the
* kernel and scheduler locks.
*/
int
-issignal(struct proc *p)
+cursig(struct proc *p)
{
struct process *pr = p->p_p;
- int signum, mask, prop;
+ int sigpending, signum, mask, prop;
int dolock = (p->p_flag & P_SINTR) == 0;
int s;
+ sigpending = (p->p_siglist | pr->ps_siglist);
+ if (sigpending == 0)
+ return 0;
+
+ if (!ISSET(pr->ps_flags, PS_TRACED) && SIGPENDING(p) == 0)
+ return 0;
+
for (;;) {
mask = SIGPENDING(p);
if (pr->ps_flags & PS_PPWAIT)
*/
if ((prop & SA_CONT) == 0 &&
(pr->ps_flags & PS_TRACED) == 0)
- printf("issignal\n");
+ printf("%s\n", __func__);
break; /* == ignore */
default:
/*
dosigsuspend(p, p->p_sigmask &~ mask);
for (;;) {
- si.si_signo = CURSIG(p);
+ si.si_signo = cursig(p);
if (si.si_signo != 0) {
sigset_t smask = sigmask(si.si_signo);
if (smask & mask) {
if (SIGPENDING(p) != 0) {
KERNEL_LOCK();
- while ((signum = CURSIG(p)) != 0)
+ while ((signum = cursig(p)) != 0)
postsig(p, signum);
KERNEL_UNLOCK();
}
p->p_sigmask = p->p_oldmask;
KERNEL_LOCK();
- while ((signum = CURSIG(p)) != 0)
+ while ((signum = cursig(p)) != 0)
postsig(p, signum);
KERNEL_UNLOCK();
}
-/* $OpenBSD: kern_synch.c,v 1.176 2021/02/08 10:51:02 mpi Exp $ */
+/* $OpenBSD: kern_synch.c,v 1.177 2021/03/04 09:02:37 mpi Exp $ */
/* $NetBSD: kern_synch.c,v 1.37 1996/04/22 01:38:37 christos Exp $ */
/*
if ((err = single_thread_check(p, 1)) != 0)
return err;
- if ((sig = CURSIG(p)) != 0) {
+ if ((sig = cursig(p)) != 0) {
if (p->p_p->ps_sigacts->ps_sigintr & sigmask(sig))
return EINTR;
else
-/* $OpenBSD: signalvar.h,v 1.45 2020/11/08 20:37:24 mpi Exp $ */
+/* $OpenBSD: signalvar.h,v 1.46 2021/03/04 09:02:38 mpi Exp $ */
/* $NetBSD: signalvar.h,v 1.17 1996/04/22 01:23:31 christos Exp $ */
/*
#define SIGPENDING(p) \
(((p)->p_siglist | (p)->p_p->ps_siglist) & ~(p)->p_sigmask)
-/*
- * Determine signal that should be delivered to process p, the current
- * process, 0 if none. If there is a pending stop signal with default
- * action, the process stops in issignal().
- */
-#define CURSIG(p) \
- ((((p)->p_siglist | (p)->p_p->ps_siglist) == 0 || \
- (((p)->p_p->ps_flags & PS_TRACED) == 0 && \
- SIGPENDING(p) == 0)) ? \
- 0 : issignal(p))
-
/*
* Clear a pending signal from a process.
*/
*/
int coredump(struct proc *p);
void execsigs(struct proc *p);
-int issignal(struct proc *p);
+int cursig(struct proc *p);
void pgsigio(struct sigio_ref *sir, int sig, int checkctty);
void pgsignal(struct pgrp *pgrp, int sig, int checkctty);
void psignal(struct proc *p, int sig);