-/* $OpenBSD: kern_sig.c,v 1.170 2014/07/11 08:18:31 guenther Exp $ */
+/* $OpenBSD: kern_sig.c,v 1.171 2014/07/12 21:21:19 matthew Exp $ */
/* $NetBSD: kern_sig.c,v 1.54 1996/04/22 01:38:32 christos Exp $ */
/*
return (0);
}
+/*
+ * Temporarily replace calling proc's signal mask for the duration of a
+ * system call. Original signal mask will be restored by userret().
+ */
+void
+dosigsuspend(struct proc *p, sigset_t newmask)
+{
+ KASSERT(p == curproc);
+
+ p->p_oldmask = p->p_sigmask;
+ atomic_setbits_int(&p->p_flag, P_SIGSUSPEND);
+ p->p_sigmask = newmask;
+}
+
/*
* Suspend process until signal, providing mask to be set
* in the meantime. Note nonstandard calling convention:
struct process *pr = p->p_p;
struct sigacts *ps = pr->ps_sigacts;
- /*
- * When returning from sigpause, we want
- * the old mask to be restored after the
- * signal handler has finished. Thus, we
- * save it here and mark the sigacts structure
- * to indicate this.
- */
- p->p_oldmask = p->p_sigmask;
- atomic_setbits_int(&p->p_flag, P_SIGSUSPEND);
- p->p_sigmask = SCARG(uap, mask) &~ sigcantmask;
+ dosigsuspend(p, SCARG(uap, mask) &~ sigcantmask);
while (tsleep(ps, PPAUSE|PCATCH, "pause", 0) == 0)
/* void */;
/* always return EINTR rather than ERESTART... */
-/* $OpenBSD: sys_generic.c,v 1.89 2014/07/12 18:43:32 tedu Exp $ */
+/* $OpenBSD: sys_generic.c,v 1.90 2014/07/12 21:21:19 matthew Exp $ */
/* $NetBSD: sys_generic.c,v 1.24 1996/03/29 00:25:32 cgd Exp $ */
/*
}
timo = 0;
- if (sigmask) {
- p->p_oldmask = p->p_sigmask;
- atomic_setbits_int(&p->p_flag, P_SIGSUSPEND);
- p->p_sigmask = *sigmask &~ sigcantmask;
- }
+ if (sigmask)
+ dosigsuspend(p, *sigmask &~ sigcantmask);
retry:
ncoll = nselcoll;
}
timo = 0;
- if (sigmask) {
- p->p_oldmask = p->p_sigmask;
- atomic_setbits_int(&p->p_flag, P_SIGSUSPEND);
- p->p_sigmask = *sigmask &~ sigcantmask;
- }
+ if (sigmask)
+ dosigsuspend(p, *sigmask &~ sigcantmask);
retry:
ncoll = nselcoll;
-/* $OpenBSD: proc.h,v 1.188 2014/07/11 08:18:31 guenther Exp $ */
+/* $OpenBSD: proc.h,v 1.189 2014/07/12 21:21:19 matthew Exp $ */
/* $NetBSD: proc.h,v 1.44 1996/04/22 01:23:21 christos Exp $ */
/*-
void *, register_t *, struct proc **);
int groupmember(gid_t, struct ucred *);
void dorefreshcreds(struct process *, struct proc *);
+void dosigsuspend(struct proc *, sigset_t);
static inline void
refreshcreds(struct proc *p)