- Move p->p_sigmask to td->td_sigmask. Signal masks will be per thread with

a follow on commit to kern_sig.c
 - signotify() now operates on a thread since unmasked pending signals are
   stored in the thread.
 - PS_NEEDSIGCHK moves to TDF_NEEDSIGCHK.
This commit is contained in:
Jeff Roberson 2003-03-31 22:49:17 +00:00
parent 0d49bb4b30
commit 4093529dee
36 changed files with 449 additions and 315 deletions

View File

@ -1501,9 +1501,9 @@ osigreturn(struct thread *td,
* sigmask is stored in sc_reserved, sc_mask is only used for
* backward compatibility.
*/
SIGSETOLD(p->p_sigmask, ksc.sc_mask);
SIG_CANTMASK(p->p_sigmask);
signotify(p);
SIGSETOLD(td->td_sigmask, ksc.sc_mask);
SIG_CANTMASK(td->td_sigmask);
signotify(td);
PROC_UNLOCK(p);
set_regs(td, (struct reg *)ksc.sc_regs);
@ -1583,9 +1583,9 @@ freebsd4_sigreturn(struct thread *td,
p->p_sigstk.ss_flags &= ~SS_ONSTACK;
#endif
p->p_sigmask = uc.uc_sigmask;
SIG_CANTMASK(p->p_sigmask);
signotify(p);
td->td_sigmask = uc.uc_sigmask;
SIG_CANTMASK(td->td_sigmask);
signotify(td);
PROC_UNLOCK(p);
/* XXX ksc.sc_ownedfp ? */
@ -1659,9 +1659,9 @@ sigreturn(struct thread *td,
p->p_sigstk.ss_flags &= ~SS_ONSTACK;
#endif
p->p_sigmask = uc.uc_sigmask;
SIG_CANTMASK(p->p_sigmask);
signotify(p);
td->td_sigmask = uc.uc_sigmask;
SIG_CANTMASK(td->td_sigmask);
signotify(td);
PROC_UNLOCK(p);
return (EJUSTRETURN);

View File

@ -451,7 +451,7 @@ osf1_signal(td, uap)
bmask = stackgap_alloc(&sg, sizeof(sigset_t));
PROC_LOCK(p);
set = p->p_sigmask;
set = td->td_sigmask;
PROC_UNLOCK(p);
SIGDELSET(set, signum);
sa.sigmask = bmask;
@ -481,7 +481,7 @@ osf1_sigprocmask(td, uap)
p = td->td_proc;
error = 0;
/* Fix the return value first if needed */
bsd_to_osf1_sigset(&p->p_sigmask, &oss);
bsd_to_osf1_sigset(&td->td_sigmask, &oss);
td->td_retval[0] = oss;
osf1_to_bsd_sigset(&uap->mask, &bss);
@ -490,19 +490,19 @@ osf1_sigprocmask(td, uap)
switch (uap->how) {
case OSF1_SIG_BLOCK:
SIGSETOR(p->p_sigmask, bss);
SIG_CANTMASK(p->p_sigmask);
SIGSETOR(td->td_sigmask, bss);
SIG_CANTMASK(td->td_sigmask);
break;
case OSF1_SIG_UNBLOCK:
SIGSETNAND(p->p_sigmask, bss);
signotify(p);
SIGSETNAND(td->td_sigmask, bss);
signotify(td);
break;
case OSF1_SIG_SETMASK:
p->p_sigmask = bss;
SIG_CANTMASK(p->p_sigmask);
signotify(p);
td->td_sigmask = bss;
SIG_CANTMASK(td->td_sigmask);
signotify(td);
break;
default:
@ -528,8 +528,9 @@ osf1_sigpending(td, uap)
p = td->td_proc;
PROC_LOCK(p);
bss = p->p_siglist;
SIGSETAND(bss, p->p_sigmask);
bss = td->td_siglist;
SIGSETOR(bss, p->p_siglist);
SIGSETAND(bss, td->td_sigmask);
PROC_UNLOCK(p);
bsd_to_osf1_sigset(&bss, &oss);
@ -727,9 +728,9 @@ osf1_sigreturn(struct thread *td,
* sigmask is stored in sc_reserved, sc_mask is only used for
* backward compatibility.
*/
osf1_to_bsd_sigset(&ksc.sc_mask, &p->p_sigmask);
SIG_CANTMASK(p->p_sigmask);
signotify(p);
osf1_to_bsd_sigset(&ksc.sc_mask, &td->td_sigmask);
SIG_CANTMASK(td->td_sigmask);
signotify(td);
PROC_UNLOCK(p);
set_regs(td, (struct reg *)ksc.sc_regs);

View File

@ -751,9 +751,9 @@ osigreturn(td, uap)
else
p->p_sigstk.ss_flags &= ~SS_ONSTACK;
#endif
SIGSETOLD(p->p_sigmask, scp->sc_mask);
SIG_CANTMASK(p->p_sigmask);
signotify(p);
SIGSETOLD(td->td_sigmask, scp->sc_mask);
SIG_CANTMASK(td->td_sigmask);
signotify(td);
PROC_UNLOCK(p);
return (EJUSTRETURN);
}
@ -859,9 +859,9 @@ freebsd4_sigreturn(td, uap)
p->p_sigstk.ss_flags &= ~SS_ONSTACK;
#endif
p->p_sigmask = ucp->uc_sigmask;
SIG_CANTMASK(p->p_sigmask);
signotify(p);
td->td_sigmask = ucp->uc_sigmask;
SIG_CANTMASK(td->td_sigmask);
signotify(td);
PROC_UNLOCK(p);
return (EJUSTRETURN);
}
@ -969,9 +969,9 @@ sigreturn(td, uap)
p->p_sigstk.ss_flags &= ~SS_ONSTACK;
#endif
p->p_sigmask = ucp->uc_sigmask;
SIG_CANTMASK(p->p_sigmask);
signotify(p);
td->td_sigmask = ucp->uc_sigmask;
SIG_CANTMASK(td->td_sigmask);
signotify(td);
PROC_UNLOCK(p);
return (EJUSTRETURN);
}

View File

@ -548,7 +548,7 @@ coda_call(mntinfo, inSize, outSize, buffer)
*/
i = 0;
PROC_LOCK(p);
psig_omask = p->p_sigmask;
psig_omask = td->td_sigmask;
do {
error = msleep(&vmp->vm_sleep, &p->p_mtx,
(coda_call_sleep|coda_pcatch), "coda_call",
@ -563,8 +563,8 @@ coda_call(mntinfo, inSize, outSize, buffer)
else {
SIGEMPTYSET(tempset);
SIGADDSET(tempset, SIGIO);
if (SIGSETEQ(p->p_siglist, tempset)) {
SIGADDSET(p->p_sigmask, SIGIO);
if (SIGSETEQ(td->td_siglist, tempset)) {
SIGADDSET(td->td_sigmask, SIGIO);
#ifdef CODA_VERBOSE
printf("coda_call: tsleep returns %d SIGIO, cnt %d\n",
error, i);
@ -572,8 +572,8 @@ coda_call(mntinfo, inSize, outSize, buffer)
} else {
SIGDELSET(tempset, SIGIO);
SIGADDSET(tempset, SIGALRM);
if (SIGSETEQ(p->p_siglist, tempset)) {
SIGADDSET(p->p_sigmask, SIGALRM);
if (SIGSETEQ(td->td_siglist, tempset)) {
SIGADDSET(td->td_sigmask, SIGALRM);
#ifdef CODA_VERBOSE
printf("coda_call: tsleep returns %d SIGALRM, cnt %d\n",
error, i);
@ -584,25 +584,25 @@ coda_call(mntinfo, inSize, outSize, buffer)
error, i);
#if notyet
tempset = p->p_siglist;
SIGSETNAND(tempset, p->p_sigmask);
tempset = td->td_siglist;
SIGSETNAND(tempset, td->td_sigmask);
printf("coda_call: siglist = %p, sigmask = %p, mask %p\n",
p->p_siglist, p->p_sigmask,
td->td_siglist, td->td_sigmask,
tempset);
break;
SIGSETOR(p->p_sigmask, p->p_siglist);
tempset = p->p_siglist;
SIGSETNAND(tempset, p->p_sigmask);
SIGSETOR(td->td_sigmask, td->td_siglist);
tempset = td->td_siglist;
SIGSETNAND(tempset, td->td_sigmask);
printf("coda_call: new mask, siglist = %p, sigmask = %p, mask %p\n",
p->p_siglist, p->p_sigmask,
td->td_siglist, td->td_sigmask,
tempset);
#endif
}
}
}
} while (error && i++ < 128 && VC_OPEN(vcp));
p->p_sigmask = psig_omask;
signotify(p);
td->td_sigmask = psig_omask;
signotify(td);
PROC_UNLOCK(p);
#else
(void) tsleep(&vmp->vm_sleep, coda_call_sleep, "coda_call", 0);

View File

@ -236,24 +236,24 @@ linux_do_sigprocmask(struct thread *td, int how, l_sigset_t *new,
PROC_LOCK(p);
if (old != NULL)
bsd_to_linux_sigset(&p->p_sigmask, old);
bsd_to_linux_sigset(&td->td_sigmask, old);
if (new != NULL) {
linux_to_bsd_sigset(new, &mask);
switch (how) {
case LINUX_SIG_BLOCK:
SIGSETOR(p->p_sigmask, mask);
SIG_CANTMASK(p->p_sigmask);
SIGSETOR(td->td_sigmask, mask);
SIG_CANTMASK(td->td_sigmask);
break;
case LINUX_SIG_UNBLOCK:
SIGSETNAND(p->p_sigmask, mask);
signotify(p);
SIGSETNAND(td->td_sigmask, mask);
signotify(td);
break;
case LINUX_SIG_SETMASK:
p->p_sigmask = mask;
SIG_CANTMASK(p->p_sigmask);
signotify(p);
td->td_sigmask = mask;
SIG_CANTMASK(td->td_sigmask);
signotify(td);
break;
default:
error = EINVAL;
@ -345,7 +345,7 @@ linux_sgetmask(struct thread *td, struct linux_sgetmask_args *args)
#endif
PROC_LOCK(p);
bsd_to_linux_sigset(&p->p_sigmask, &mask);
bsd_to_linux_sigset(&td->td_sigmask, &mask);
PROC_UNLOCK(p);
td->td_retval[0] = mask.__bits[0];
return (0);
@ -364,14 +364,14 @@ linux_ssetmask(struct thread *td, struct linux_ssetmask_args *args)
#endif
PROC_LOCK(p);
bsd_to_linux_sigset(&p->p_sigmask, &lset);
bsd_to_linux_sigset(&td->td_sigmask, &lset);
td->td_retval[0] = lset.__bits[0];
LINUX_SIGEMPTYSET(lset);
lset.__bits[0] = args->mask;
linux_to_bsd_sigset(&lset, &bset);
p->p_sigmask = bset;
SIG_CANTMASK(p->p_sigmask);
signotify(p);
td->td_sigmask = bset;
SIG_CANTMASK(td->td_sigmask);
signotify(td);
PROC_UNLOCK(p);
return (0);
}
@ -394,7 +394,8 @@ linux_sigpending(struct thread *td, struct linux_sigpending_args *args)
PROC_LOCK(p);
bset = p->p_siglist;
SIGSETAND(bset, p->p_sigmask);
SIGSETOR(bset, td->td_siglist);
SIGSETAND(bset, td->td_sigmask);
bsd_to_linux_sigset(&bset, &lset);
PROC_UNLOCK(p);
mask = lset.__bits[0];

View File

@ -132,10 +132,10 @@ svr4_sys_read(td, uap)
DPRINTF(("svr4_read(%d, 0x%0x, %d) = %d\n",
uap->fd, uap->buf, uap->nbyte, rv));
if (rv == EAGAIN) {
DPRINTF(("sigmask = 0x%x\n", td->td_proc->p_sigmask));
DPRINTF(("sigmask = 0x%x\n", td->td_sigmask));
DPRINTF(("sigignore = 0x%x\n", td->td_proc->p_sigignore));
DPRINTF(("sigcaught = 0x%x\n", td->td_proc->p_sigcatch));
DPRINTF(("siglist = 0x%x\n", td->td_proc->p_siglist));
DPRINTF(("siglist = 0x%x\n", td->td_siglist));
}
#if defined(GROTTY_READ_HACK)

View File

@ -481,7 +481,7 @@ svr4_sys_signal(td, uap)
set = stackgap_alloc(&sg, sizeof(sigset_t));
PROC_LOCK(td->td_proc);
*set = td->td_proc->p_sigmask;
*set = td->td_sigmask;
PROC_UNLOCK(td->td_proc);
SIGDELSET(*set, signum);
sa.sigmask = set;
@ -507,7 +507,7 @@ svr4_sys_sigprocmask(td, uap)
if (uap->oset != NULL) {
/* Fix the return value first if needed */
PROC_LOCK(td->td_proc);
bsd_to_svr4_sigset(&td->td_proc->p_sigmask, &sss);
bsd_to_svr4_sigset(&td->td_sigmask, &sss);
PROC_UNLOCK(td->td_proc);
if ((error = copyout(&sss, uap->oset, sizeof(sss))) != 0)
return error;
@ -525,19 +525,19 @@ svr4_sys_sigprocmask(td, uap)
PROC_LOCK(td->td_proc);
switch (uap->how) {
case SVR4_SIG_BLOCK:
SIGSETOR(td->td_proc->p_sigmask, bss);
SIG_CANTMASK(td->td_proc->p_sigmask);
SIGSETOR(td->td_sigmask, bss);
SIG_CANTMASK(td->td_sigmask);
break;
case SVR4_SIG_UNBLOCK:
SIGSETNAND(td->td_proc->p_sigmask, bss);
signotify(td->td_proc);
SIGSETNAND(td->td_sigmask, bss);
signotify(td);
break;
case SVR4_SIG_SETMASK:
td->td_proc->p_sigmask = bss;
SIG_CANTMASK(td->td_proc->p_sigmask);
signotify(td->td_proc);
td->td_sigmask = bss;
SIG_CANTMASK(td->td_sigmask);
signotify(td);
break;
default:
@ -566,7 +566,8 @@ svr4_sys_sigpending(td, uap)
return 0;
PROC_LOCK(td->td_proc);
bss = td->td_proc->p_siglist;
SIGSETAND(bss, td->td_proc->p_sigmask);
SIGSETOR(bss, td->td_siglist);
SIGSETAND(bss, td->td_sigmask);
PROC_UNLOCK(td->td_proc);
bsd_to_svr4_sigset(&bss, &sss);
break;
@ -636,7 +637,7 @@ svr4_sys_context(td, uap)
case 0:
PROC_LOCK(td->td_proc);
DPRINTF(("getcontext(%p)\n", uap->uc));
svr4_getcontext(td, &uc, &td->td_proc->p_sigmask,
svr4_getcontext(td, &uc, &td->td_sigmask,
sigonstack(cpu_getstack(td)));
PROC_UNLOCK(td->td_proc);
return copyout(&uc, uap->uc, sizeof(uc));
@ -671,6 +672,6 @@ svr4_sys_pause(td, uap)
{
struct sigsuspend_args bsa;
bsa.sigmask = &td->td_proc->p_sigmask;
bsa.sigmask = &td->td_sigmask;
return sigsuspend(td, &bsa);
}

View File

@ -548,7 +548,7 @@ coda_call(mntinfo, inSize, outSize, buffer)
*/
i = 0;
PROC_LOCK(p);
psig_omask = p->p_sigmask;
psig_omask = td->td_sigmask;
do {
error = msleep(&vmp->vm_sleep, &p->p_mtx,
(coda_call_sleep|coda_pcatch), "coda_call",
@ -563,8 +563,8 @@ coda_call(mntinfo, inSize, outSize, buffer)
else {
SIGEMPTYSET(tempset);
SIGADDSET(tempset, SIGIO);
if (SIGSETEQ(p->p_siglist, tempset)) {
SIGADDSET(p->p_sigmask, SIGIO);
if (SIGSETEQ(td->td_siglist, tempset)) {
SIGADDSET(td->td_sigmask, SIGIO);
#ifdef CODA_VERBOSE
printf("coda_call: tsleep returns %d SIGIO, cnt %d\n",
error, i);
@ -572,8 +572,8 @@ coda_call(mntinfo, inSize, outSize, buffer)
} else {
SIGDELSET(tempset, SIGIO);
SIGADDSET(tempset, SIGALRM);
if (SIGSETEQ(p->p_siglist, tempset)) {
SIGADDSET(p->p_sigmask, SIGALRM);
if (SIGSETEQ(td->td_siglist, tempset)) {
SIGADDSET(td->td_sigmask, SIGALRM);
#ifdef CODA_VERBOSE
printf("coda_call: tsleep returns %d SIGALRM, cnt %d\n",
error, i);
@ -584,25 +584,25 @@ coda_call(mntinfo, inSize, outSize, buffer)
error, i);
#if notyet
tempset = p->p_siglist;
SIGSETNAND(tempset, p->p_sigmask);
tempset = td->td_siglist;
SIGSETNAND(tempset, td->td_sigmask);
printf("coda_call: siglist = %p, sigmask = %p, mask %p\n",
p->p_siglist, p->p_sigmask,
td->td_siglist, td->td_sigmask,
tempset);
break;
SIGSETOR(p->p_sigmask, p->p_siglist);
tempset = p->p_siglist;
SIGSETNAND(tempset, p->p_sigmask);
SIGSETOR(td->td_sigmask, td->td_siglist);
tempset = td->td_siglist;
SIGSETNAND(tempset, td->td_sigmask);
printf("coda_call: new mask, siglist = %p, sigmask = %p, mask %p\n",
p->p_siglist, p->p_sigmask,
td->td_siglist, td->td_sigmask,
tempset);
#endif
}
}
}
} while (error && i++ < 128 && VC_OPEN(vcp));
p->p_sigmask = psig_omask;
signotify(p);
td->td_sigmask = psig_omask;
signotify(td);
PROC_UNLOCK(p);
#else
(void) tsleep(&vmp->vm_sleep, coda_call_sleep, "coda_call", 0);

View File

@ -751,9 +751,9 @@ osigreturn(td, uap)
else
p->p_sigstk.ss_flags &= ~SS_ONSTACK;
#endif
SIGSETOLD(p->p_sigmask, scp->sc_mask);
SIG_CANTMASK(p->p_sigmask);
signotify(p);
SIGSETOLD(td->td_sigmask, scp->sc_mask);
SIG_CANTMASK(td->td_sigmask);
signotify(td);
PROC_UNLOCK(p);
return (EJUSTRETURN);
}
@ -859,9 +859,9 @@ freebsd4_sigreturn(td, uap)
p->p_sigstk.ss_flags &= ~SS_ONSTACK;
#endif
p->p_sigmask = ucp->uc_sigmask;
SIG_CANTMASK(p->p_sigmask);
signotify(p);
td->td_sigmask = ucp->uc_sigmask;
SIG_CANTMASK(td->td_sigmask);
signotify(td);
PROC_UNLOCK(p);
return (EJUSTRETURN);
}
@ -969,9 +969,9 @@ sigreturn(td, uap)
p->p_sigstk.ss_flags &= ~SS_ONSTACK;
#endif
p->p_sigmask = ucp->uc_sigmask;
SIG_CANTMASK(p->p_sigmask);
signotify(p);
td->td_sigmask = ucp->uc_sigmask;
SIG_CANTMASK(td->td_sigmask);
signotify(td);
PROC_UNLOCK(p);
return (EJUSTRETURN);
}

View File

@ -324,11 +324,11 @@ ibcs2_sigsys(td, uap)
if(IBCS2_SIGCALL(uap->sig) == IBCS2_SIGSET_MASK) {
PROC_LOCK(p);
/* check to make sure signal is not blocked */
if(sigismember(&p->p_sigmask, signum)) {
if(sigismember(&td->td_sigmask, signum)) {
/* return SIG_HOLD and unblock signal*/
td->td_retval[0] = (int)IBCS2_SIG_HOLD;
SIGDELSET(p->p_sigmask, signum);
signotify(p);
SIGDELSET(td->td_sigmask, signum);
signotify(td);
}
PROC_UNLOCK(p);
}
@ -377,7 +377,7 @@ ibcs2_sigsys(td, uap)
struct sigsuspend_args sa;
PROC_LOCK(p);
mask = p->p_sigmask;
mask = td->td_sigmask;
PROC_UNLOCK(p);
SIGDELSET(mask, signum);
sa.sigmask = &mask;
@ -402,7 +402,7 @@ ibcs2_sigprocmask(td, uap)
if (uap->oset != NULL) {
/* Fix the return value first if needed */
PROC_LOCK(p);
bsd_to_ibcs2_sigset(&p->p_sigmask, &iss);
bsd_to_ibcs2_sigset(&td->td_sigmask, &iss);
PROC_UNLOCK(p);
if ((error = copyout(&iss, uap->oset, sizeof(iss))) != 0)
return error;
@ -421,19 +421,19 @@ ibcs2_sigprocmask(td, uap)
switch (uap->how) {
case IBCS2_SIG_BLOCK:
SIGSETOR(p->p_sigmask, bss);
SIG_CANTMASK(p->p_sigmask);
SIGSETOR(td->td_sigmask, bss);
SIG_CANTMASK(td->td_sigmask);
break;
case IBCS2_SIG_UNBLOCK:
SIGSETNAND(p->p_sigmask, bss);
signotify(p);
SIGSETNAND(td->td_sigmask, bss);
signotify(td);
break;
case IBCS2_SIG_SETMASK:
p->p_sigmask = bss;
SIG_CANTMASK(p->p_sigmask);
signotify(p);
td->td_sigmask = bss;
SIG_CANTMASK(td->td_sigmask);
signotify(td);
break;
default:
@ -456,8 +456,9 @@ ibcs2_sigpending(td, uap)
ibcs2_sigset_t iss;
PROC_LOCK(p);
bss = p->p_siglist;
SIGSETAND(bss, p->p_sigmask);
bss = td->td_siglist;
SIGSETOR(bss, p->p_siglist);
SIGSETAND(bss, td->td_sigmask);
PROC_UNLOCK(p);
bsd_to_ibcs2_sigset(&bss, &iss);
@ -492,7 +493,7 @@ ibcs2_pause(td, uap)
struct sigsuspend_args sa;
PROC_LOCK(p);
mask = td->td_proc->p_sigmask;
mask = td->td_sigmask;
PROC_UNLOCK(p);
sa.sigmask = &mask;
return sigsuspend(td, &sa);

View File

@ -772,7 +772,7 @@ linux_pause(struct thread *td, struct linux_pause_args *args)
#endif
PROC_LOCK(p);
sigmask = p->p_sigmask;
sigmask = td->td_sigmask;
PROC_UNLOCK(p);
return (kern_sigsuspend(td, sigmask));
}

View File

@ -562,9 +562,9 @@ linux_sigreturn(struct thread *td, struct linux_sigreturn_args *args)
for (i = 0; i < (LINUX_NSIG_WORDS-1); i++)
lmask.__bits[i+1] = frame.sf_extramask[i];
PROC_LOCK(p);
linux_to_bsd_sigset(&lmask, &p->p_sigmask);
SIG_CANTMASK(p->p_sigmask);
signotify(p);
linux_to_bsd_sigset(&lmask, &td->td_sigmask);
SIG_CANTMASK(td->td_sigmask);
signotify(td);
PROC_UNLOCK(p);
/*
@ -657,9 +657,9 @@ linux_rt_sigreturn(struct thread *td, struct linux_rt_sigreturn_args *args)
}
PROC_LOCK(p);
linux_to_bsd_sigset(&uc.uc_sigmask, &p->p_sigmask);
SIG_CANTMASK(p->p_sigmask);
signotify(p);
linux_to_bsd_sigset(&uc.uc_sigmask, &td->td_sigmask);
SIG_CANTMASK(td->td_sigmask);
signotify(td);
PROC_UNLOCK(p);
/*

View File

@ -293,8 +293,8 @@ svr4_setcontext(td, uc)
#endif
svr4_to_bsd_sigset(&uc->uc_sigmask, &mask);
SIG_CANTMASK(mask);
p->p_sigmask = mask;
signotify(p);
td->td_sigmask = mask;
signotify(td);
}
PROC_UNLOCK(p);

View File

@ -988,9 +988,9 @@ sigreturn(struct thread *td,
p->p_sigstk.ss_flags &= ~SS_ONSTACK;
#endif
p->p_sigmask = uc.uc_sigmask;
SIG_CANTMASK(p->p_sigmask);
signotify(p);
td->td_sigmask = uc.uc_sigmask;
SIG_CANTMASK(td->td_sigmask);
signotify(td);
PROC_UNLOCK(p);
/* XXX ksc.sc_ownedfp ? */

View File

@ -73,7 +73,7 @@ getcontext(struct thread *td, struct getcontext_args *uap)
ret = EINVAL;
else {
get_mcontext(td, &uc.uc_mcontext);
uc.uc_sigmask = td->td_proc->p_sigmask;
uc.uc_sigmask = td->td_sigmask;
ret = copyout(&uc, uap->ucp, UC_COPY_SIZE);
}
return (ret);
@ -97,7 +97,7 @@ setcontext(struct thread *td, struct setcontext_args *uap)
if (ret == 0) {
SIG_CANTMASK(uc.uc_sigmask);
PROC_LOCK(td->td_proc);
td->td_proc->p_sigmask = uc.uc_sigmask;
td->td_sigmask = uc.uc_sigmask;
PROC_UNLOCK(td->td_proc);
}
}
@ -115,7 +115,7 @@ swapcontext(struct thread *td, struct swapcontext_args *uap)
ret = EINVAL;
else {
get_mcontext(td, &uc.uc_mcontext);
uc.uc_sigmask = td->td_proc->p_sigmask;
uc.uc_sigmask = td->td_sigmask;
ret = copyout(&uc, uap->oucp, UC_COPY_SIZE);
if (ret == 0) {
ret = copyin(uap->ucp, &uc, UC_COPY_SIZE);
@ -124,7 +124,7 @@ swapcontext(struct thread *td, struct swapcontext_args *uap)
if (ret == 0) {
SIG_CANTMASK(uc.uc_sigmask);
PROC_LOCK(td->td_proc);
td->td_proc->p_sigmask = uc.uc_sigmask;
td->td_sigmask = uc.uc_sigmask;
PROC_UNLOCK(td->td_proc);
}
}

View File

@ -217,6 +217,7 @@ exit1(struct thread *td, int rv)
stopprofclock(p);
p->p_flag &= ~(P_TRACED | P_PPWAIT);
SIGEMPTYSET(p->p_siglist);
SIGEMPTYSET(td->td_siglist);
if (timevalisset(&p->p_realtimer.it_value))
callout_stop(&p->p_itcallout);
PROC_UNLOCK(p);

View File

@ -496,8 +496,10 @@ kse_release(struct thread *td, struct kse_release_args *uap)
mtx_lock_spin(&sched_lock);
/* Change OURSELF to become an upcall. */
td->td_flags = TDF_UPCALLING;
#if 0 /* XXX This shouldn't be necessary */
if (p->p_sflag & PS_NEEDSIGCHK)
td->td_flags |= TDF_ASTPENDING;
#endif
mtx_unlock_spin(&sched_lock);
PROC_LOCK(p);
while ((td->td_upcall->ku_flags & KUF_DOUPCALL) == 0 &&
@ -744,7 +746,7 @@ thread_getcontext(struct thread *td, ucontext_t *uc)
#ifdef __i386__
get_mcontext(td, &uc->uc_mcontext);
#endif
uc->uc_sigmask = td->td_proc->p_sigmask;
uc->uc_sigmask = td->td_sigmask;
}
/*
@ -769,7 +771,7 @@ thread_setcontext(struct thread *td, ucontext_t *uc)
if (ret == 0) {
SIG_CANTMASK(uc->uc_sigmask);
PROC_LOCK(td->td_proc);
td->td_proc->p_sigmask = uc->uc_sigmask;
td->td_sigmask = uc->uc_sigmask;
PROC_UNLOCK(td->td_proc);
}
return (ret);
@ -1247,6 +1249,7 @@ thread_exit(void)
} else {
PROC_UNLOCK(p);
}
/* XXX Shouldn't cpu_throw() here. */
cpu_throw();
/* NOTREACHED */
}
@ -1428,8 +1431,10 @@ thread_schedule_upcall(struct thread *td, struct kse_upcall *ku)
ku->ku_owner = td2;
td2->td_upcall = ku;
td2->td_flags = TDF_UPCALLING;
#if 0 /* XXX This shouldn't be necessary */
if (td->td_proc->p_sflag & PS_NEEDSIGCHK)
td2->td_flags |= TDF_ASTPENDING;
#endif
td2->td_kse = NULL;
td2->td_state = TDS_CAN_RUN;
td2->td_inhibitors = 0;
@ -1593,6 +1598,7 @@ thread_userret(struct thread *td, struct trapframe *frame)
p = td->td_proc;
kg = td->td_ksegrp;
/* Nothing to do with non-threaded group/process */
if (td->td_ksegrp->kg_numupcalls == 0)
return (0);
@ -1621,12 +1627,12 @@ thread_userret(struct thread *td, struct trapframe *frame)
if (TD_CAN_UNBIND(td)) {
mtx_lock_spin(&sched_lock);
td->td_flags &= ~TDF_CAN_UNBIND;
mtx_unlock_spin(&sched_lock);
ku = td->td_upcall;
if ((p->p_sflag & PS_NEEDSIGCHK) == 0 &&
if ((td->td_flags & TDF_NEEDSIGCHK) == 0 &&
(kg->kg_completed == NULL) &&
(ku->ku_flags & KUF_DOUPCALL) == 0 &&
(kg->kg_upquantum && ticks >= kg->kg_nextupcall)) {
mtx_unlock_spin(&sched_lock);
thread_update_usr_ticks(td, 0);
nanotime(&ts);
error = copyout(&ts,
@ -1637,6 +1643,7 @@ thread_userret(struct thread *td, struct trapframe *frame)
goto out;
return (0);
}
mtx_unlock_spin(&sched_lock);
error = thread_export_context(td);
if (error) {
/*

View File

@ -610,12 +610,15 @@ fill_kinfo_proc(p, kp)
struct kinfo_proc *kp;
{
struct thread *td;
struct thread *td0;
struct kse *ke;
struct ksegrp *kg;
struct tty *tp;
struct session *sp;
struct timeval tv;
td = FIRST_THREAD_IN_PROC(p);
bzero(kp, sizeof(*kp));
kp->ki_structsize = sizeof(*kp);
@ -657,7 +660,7 @@ fill_kinfo_proc(p, kp)
kp->ki_rssize = vmspace_resident_count(vm); /*XXX*/
if (p->p_sflag & PS_INMEM)
kp->ki_rssize += UAREA_PAGES;
FOREACH_THREAD_IN_PROC(p, td) /* XXXKSE: thread swapout check */
FOREACH_THREAD_IN_PROC(p, td0)/* XXXKSE: thread swapout check */
kp->ki_rssize += KSTACK_PAGES;
kp->ki_swrss = vm->vm_swrss;
kp->ki_tsize = vm->vm_tsize;
@ -673,7 +676,6 @@ fill_kinfo_proc(p, kp)
p->p_stats->p_cru.ru_stime.tv_usec;
}
if (p->p_state != PRS_ZOMBIE) {
td = FIRST_THREAD_IN_PROC(p);
if (td == NULL) {
/* XXXKSE: This should never happen. */
printf("fill_kinfo_proc(): pid %d has no threads!\n",
@ -786,7 +788,8 @@ fill_kinfo_proc(p, kp)
strlcpy(kp->ki_ocomm, p->p_comm, sizeof(kp->ki_ocomm));
}
kp->ki_siglist = p->p_siglist;
kp->ki_sigmask = p->p_sigmask;
SIGSETOR(kp->ki_siglist, td->td_siglist);
kp->ki_sigmask = td->td_sigmask;
kp->ki_xstat = p->p_xstat;
kp->ki_acflag = p->p_acflag;
kp->ki_flag = p->p_flag;

View File

@ -80,17 +80,15 @@
#define ONSIG 32 /* NSIG for osig* syscalls. XXX. */
static int coredump(struct thread *);
static int do_sigprocmask(struct proc *p, int how, sigset_t *set,
sigset_t *oset, int old);
static char *expand_name(const char *, uid_t, pid_t);
static int killpg1(struct thread *td, int sig, int pgid, int all);
static int sig_ffs(sigset_t *set);
static int sigprop(int sig);
static void stop(struct proc *);
static void tdsignal(struct thread *td, int sig, sig_t action);
static void tdsigwakeup(struct thread *td, int sig, sig_t action);
static int filt_sigattach(struct knote *kn);
static void filt_sigdetach(struct knote *kn);
static int filt_signal(struct knote *kn, long hint);
static struct thread *sigtd(struct proc *p, int sig, int prop);
struct filterops sig_filtops =
{ 0, filt_sigattach, filt_sigdetach, filt_signal };
@ -183,31 +181,36 @@ cursig(struct thread *td)
PROC_LOCK_ASSERT(p, MA_OWNED);
mtx_assert(&sched_lock, MA_NOTOWNED);
return (SIGPENDING(p) ? issignal(td) : 0);
return (SIGPENDING(td) ? issignal(td) : 0);
}
/*
* Arrange for ast() to handle unmasked pending signals on return to user
* mode. This must be called whenever a signal is added to p_siglist or
* unmasked in p_sigmask.
* mode. This must be called whenever a signal is added to td_siglist or
* unmasked in td_sigmask.
*/
void
signotify(struct proc *p)
signotify(struct thread *td)
{
struct thread *td;
struct ksegrp *kg;
struct proc *p;
sigset_t set;
p = td->td_proc;
PROC_LOCK_ASSERT(p, MA_OWNED);
/*
* If our mask changed we may have to move signal that were
* previously masked by all threads to our siglist.
*/
set = p->p_siglist;
SIGSETNAND(set, td->td_sigmask);
SIGSETNAND(p->p_siglist, set);
SIGSETOR(td->td_siglist, set);
mtx_lock_spin(&sched_lock);
if (SIGPENDING(p)) {
p->p_sflag |= PS_NEEDSIGCHK;
/* XXXKSE for now punish all KSEs */
FOREACH_KSEGRP_IN_PROC(p, kg) {
FOREACH_THREAD_IN_GROUP(kg, td) {
td->td_flags |= TDF_ASTPENDING;
}
}
}
if (SIGPENDING(td))
td->td_flags |= TDF_NEEDSIGCHK | TDF_ASTPENDING;
mtx_unlock_spin(&sched_lock);
}
@ -220,7 +223,7 @@ sigprop(int sig)
return (0);
}
static __inline int
int
sig_ffs(sigset_t *set)
{
int i;
@ -245,6 +248,7 @@ kern_sigaction(td, sig, act, oact, flags)
int flags;
{
register struct sigacts *ps;
struct thread *td0;
struct proc *p = td->td_proc;
if (!_SIG_VALID(sig))
@ -348,6 +352,8 @@ kern_sigaction(td, sig, act, oact, flags)
ps->ps_sigact[_SIG_IDX(sig)] == SIG_DFL)) {
/* never to be seen again */
SIGDELSET(p->p_siglist, sig);
FOREACH_THREAD_IN_PROC(p, td0)
SIGDELSET(td0->td_siglist, sig);
if (sig != SIGCONT)
/* easier in psignal */
SIGADDSET(p->p_sigignore, sig);
@ -542,7 +548,7 @@ execsigs(p)
/*
* Reset caught signals. Held signals remain held
* through p_sigmask (unless they were caught,
* through td_sigmask (unless they were caught,
* and are now ignored by default).
*/
PROC_LOCK_ASSERT(p, MA_OWNED);
@ -554,9 +560,17 @@ execsigs(p)
if (sig != SIGCONT)
SIGADDSET(p->p_sigignore, sig);
SIGDELSET(p->p_siglist, sig);
/*
* There is only one thread at this point.
*/
SIGDELSET(FIRST_THREAD_IN_PROC(p)->td_siglist, sig);
}
ps->ps_sigact[_SIG_IDX(sig)] = SIG_DFL;
}
/*
* Clear out the td's sigmask. Normal processes use the proc sigmask.
*/
SIGEMPTYSET(FIRST_THREAD_IN_PROC(p)->td_sigmask);
/*
* Reset stack state to the user stack.
* Clear set of signals caught on the signal stack.
@ -578,44 +592,44 @@ execsigs(p)
*
* Manipulate signal mask.
*/
static int
do_sigprocmask(p, how, set, oset, old)
struct proc *p;
int
do_sigprocmask(td, how, set, oset, old)
struct thread *td;
int how;
sigset_t *set, *oset;
int old;
{
int error;
PROC_LOCK(p);
PROC_LOCK(td->td_proc);
if (oset != NULL)
*oset = p->p_sigmask;
*oset = td->td_sigmask;
error = 0;
if (set != NULL) {
switch (how) {
case SIG_BLOCK:
SIG_CANTMASK(*set);
SIGSETOR(p->p_sigmask, *set);
SIGSETOR(td->td_sigmask, *set);
break;
case SIG_UNBLOCK:
SIGSETNAND(p->p_sigmask, *set);
signotify(p);
SIGSETNAND(td->td_sigmask, *set);
signotify(td);
break;
case SIG_SETMASK:
SIG_CANTMASK(*set);
if (old)
SIGSETLO(p->p_sigmask, *set);
SIGSETLO(td->td_sigmask, *set);
else
p->p_sigmask = *set;
signotify(p);
td->td_sigmask = *set;
signotify(td);
break;
default:
error = EINVAL;
break;
}
}
PROC_UNLOCK(p);
PROC_UNLOCK(td->td_proc);
return (error);
}
@ -635,7 +649,6 @@ sigprocmask(td, uap)
register struct thread *td;
struct sigprocmask_args *uap;
{
struct proc *p = td->td_proc;
sigset_t set, oset;
sigset_t *setp, *osetp;
int error;
@ -647,7 +660,7 @@ sigprocmask(td, uap)
if (error)
return (error);
}
error = do_sigprocmask(p, uap->how, setp, osetp, 0);
error = do_sigprocmask(td, uap->how, setp, osetp, 0);
if (osetp && !error) {
error = copyout(osetp, uap->oset, sizeof(oset));
}
@ -669,12 +682,11 @@ osigprocmask(td, uap)
register struct thread *td;
struct osigprocmask_args *uap;
{
struct proc *p = td->td_proc;
sigset_t set, oset;
int error;
OSIG2SIG(uap->mask, set);
error = do_sigprocmask(p, uap->how, &set, &oset, 1);
error = do_sigprocmask(td, uap->how, &set, &oset, 1);
SIG2OSIG(oset, td->td_retval[0]);
return (error);
}
@ -698,6 +710,7 @@ sigpending(td, uap)
PROC_LOCK(p);
siglist = p->p_siglist;
SIGSETOR(siglist, td->td_siglist);
PROC_UNLOCK(p);
return (copyout(&siglist, uap->set, sizeof(sigset_t)));
}
@ -717,9 +730,12 @@ osigpending(td, uap)
struct osigpending_args *uap;
{
struct proc *p = td->td_proc;
sigset_t siglist;
PROC_LOCK(p);
SIG2OSIG(p->p_siglist, td->td_retval[0]);
siglist = p->p_siglist;
SIGSETOR(siglist, td->td_siglist);
SIG2OSIG(siglist, td->td_retval[0]);
PROC_UNLOCK(p);
return (0);
}
@ -803,8 +819,8 @@ osigblock(td, uap)
SIG_CANTMASK(set);
mtx_lock(&Giant);
PROC_LOCK(p);
SIG2OSIG(p->p_sigmask, td->td_retval[0]);
SIGSETOR(p->p_sigmask, set);
SIG2OSIG(td->td_sigmask, td->td_retval[0]);
SIGSETOR(td->td_sigmask, set);
PROC_UNLOCK(p);
mtx_unlock(&Giant);
return (0);
@ -830,9 +846,9 @@ osigsetmask(td, uap)
SIG_CANTMASK(set);
mtx_lock(&Giant);
PROC_LOCK(p);
SIG2OSIG(p->p_sigmask, td->td_retval[0]);
SIGSETLO(p->p_sigmask, set);
signotify(p);
SIG2OSIG(td->td_sigmask, td->td_retval[0]);
SIGSETLO(td->td_sigmask, set);
signotify(td);
PROC_UNLOCK(p);
mtx_unlock(&Giant);
return (0);
@ -886,12 +902,13 @@ kern_sigsuspend(struct thread *td, sigset_t mask)
mtx_lock(&Giant);
PROC_LOCK(p);
ps = p->p_sigacts;
p->p_oldsigmask = p->p_sigmask;
p->p_flag |= P_OLDMASK;
td->td_oldsigmask = td->td_sigmask;
mtx_lock_spin(&sched_lock);
td->td_flags |= TDF_OLDMASK;
mtx_unlock_spin(&sched_lock);
SIG_CANTMASK(mask);
p->p_sigmask = mask;
signotify(p);
td->td_sigmask = mask;
signotify(td);
while (msleep(ps, &p->p_mtx, PPAUSE|PCATCH, "pause", 0) == 0)
/* void */;
PROC_UNLOCK(p);
@ -922,12 +939,14 @@ osigsuspend(td, uap)
mtx_lock(&Giant);
PROC_LOCK(p);
ps = p->p_sigacts;
p->p_oldsigmask = p->p_sigmask;
p->p_flag |= P_OLDMASK;
td->td_oldsigmask = td->td_sigmask;
mtx_lock_spin(&sched_lock);
td->td_flags |= TDF_OLDMASK;
mtx_unlock_spin(&sched_lock);
OSIG2SIG(uap->mask, mask);
SIG_CANTMASK(mask);
SIGSETLO(p->p_sigmask, mask);
signotify(p);
SIGSETLO(td->td_sigmask, mask);
signotify(td);
while (msleep(ps, &p->p_mtx, PPAUSE|PCATCH, "opause", 0) == 0)
/* void */;
PROC_UNLOCK(p);
@ -1274,18 +1293,18 @@ trapsignal(struct thread *td, int sig, u_long code)
PROC_LOCK(p);
ps = p->p_sigacts;
if ((p->p_flag & P_TRACED) == 0 && SIGISMEMBER(p->p_sigcatch, sig) &&
!SIGISMEMBER(p->p_sigmask, sig)) {
!SIGISMEMBER(td->td_sigmask, sig)) {
p->p_stats->p_ru.ru_nsignals++;
#ifdef KTRACE
if (KTRPOINT(curthread, KTR_PSIG))
ktrpsig(sig, ps->ps_sigact[_SIG_IDX(sig)],
&p->p_sigmask, code);
&td->td_sigmask, code);
#endif
(*p->p_sysent->sv_sendsig)(ps->ps_sigact[_SIG_IDX(sig)], sig,
&p->p_sigmask, code);
SIGSETOR(p->p_sigmask, ps->ps_catchmask[_SIG_IDX(sig)]);
&td->td_sigmask, code);
SIGSETOR(td->td_sigmask, ps->ps_catchmask[_SIG_IDX(sig)]);
if (!SIGISMEMBER(ps->ps_signodefer, sig))
SIGADDSET(p->p_sigmask, sig);
SIGADDSET(td->td_sigmask, sig);
if (SIGISMEMBER(ps->ps_sigreset, sig)) {
/*
* See kern_sigaction() for origin of this code.
@ -1299,11 +1318,45 @@ trapsignal(struct thread *td, int sig, u_long code)
} else {
p->p_code = code; /* XXX for core dump/debugger */
p->p_sig = sig; /* XXX to verify code */
psignal(p, sig);
tdsignal(td, sig);
}
PROC_UNLOCK(p);
}
static struct thread *
sigtd(struct proc *p, int sig, int prop)
{
struct thread *td;
PROC_LOCK_ASSERT(p, MA_OWNED);
/*
* If we know the signal is bound for a specific thread then we
* assume that we are in that threads context. This is the case
* for SIGXCPU, SIGILL, etc. Otherwise someone did a kill() from
* userland and the real thread doesn't actually matter.
*/
if ((prop & SA_PROC) != 0 && curthread->td_proc == p)
return (curthread);
/*
* We should search for the first thread that is blocked in
* sigsuspend with this signal unmasked.
*/
/* XXX */
/*
* Find the first thread in the proc that doesn't have this signal
* masked.
*/
FOREACH_THREAD_IN_PROC(p, td)
if (!SIGISMEMBER(td->td_sigmask, sig))
return (td);
return (FIRST_THREAD_IN_PROC(p));
}
/*
* Send the signal to the process. If the signal has an action, the action
* is usually performed by the target process rather than the caller; we add
@ -1318,22 +1371,51 @@ trapsignal(struct thread *td, int sig, u_long code)
* Other ignored signals are discarded immediately.
*/
void
psignal(p, sig)
register struct proc *p;
register int sig;
psignal(struct proc *p, int sig)
{
register sig_t action;
struct thread *td;
int prop;
PROC_LOCK_ASSERT(p, MA_OWNED);
prop = sigprop(sig);
/*
* Find a thread to deliver the signal to.
*/
td = sigtd(p, sig, prop);
tdsignal(td, sig);
}
void
tdsignal(struct thread *td, int sig)
{
struct proc *p;
register sig_t action;
sigset_t *siglist;
struct thread *td0;
register int prop;
KASSERT(_SIG_VALID(sig),
("psignal(): invalid signal %d\n", sig));
("tdsignal(): invalid signal %d\n", sig));
p = td->td_proc;
PROC_LOCK_ASSERT(p, MA_OWNED);
KNOTE(&p->p_klist, NOTE_SIGNAL | sig);
prop = sigprop(sig);
/*
* If this thread is blocking this signal then we'll leave it in the
* proc so that we can find it in the first thread that unblocks it.
*/
if (SIGISMEMBER(td->td_sigmask, sig))
siglist = &p->p_siglist;
else
siglist = &td->td_siglist;
/*
* If proc is traced, always give parent a chance;
* if signal event is tracked by procfs, give *that*
@ -1351,7 +1433,7 @@ psignal(p, sig)
*/
if (SIGISMEMBER(p->p_sigignore, sig) || (p->p_flag & P_WEXIT))
return;
if (SIGISMEMBER(p->p_sigmask, sig))
if (SIGISMEMBER(td->td_sigmask, sig))
action = SIG_HOLD;
else if (SIGISMEMBER(p->p_sigcatch, sig))
action = SIG_CATCH;
@ -1359,8 +1441,15 @@ psignal(p, sig)
action = SIG_DFL;
}
if (prop & SA_CONT)
if (prop & SA_CONT) {
SIG_STOPSIGMASK(p->p_siglist);
/*
* XXX Should investigate leaving STOP and CONT sigs only in
* the proc's siglist.
*/
FOREACH_THREAD_IN_PROC(p, td0)
SIG_STOPSIGMASK(td0->td_siglist);
}
if (prop & SA_STOP) {
/*
@ -1374,10 +1463,12 @@ psignal(p, sig)
(action == SIG_DFL))
return;
SIG_CONTSIGMASK(p->p_siglist);
FOREACH_THREAD_IN_PROC(p, td0)
SIG_CONTSIGMASK(td0->td_siglist);
p->p_flag &= ~P_CONTINUED;
}
SIGADDSET(p->p_siglist, sig);
signotify(p); /* uses schedlock */
SIGADDSET(*siglist, sig);
signotify(td); /* uses schedlock */
/*
* Some signals have a process-wide effect and a per-thread
@ -1414,10 +1505,10 @@ psignal(p, sig)
if (prop & SA_CONT) {
/*
* If SIGCONT is default (or ignored), we continue the
* process but don't leave the signal in p_siglist as
* process but don't leave the signal in siglist as
* it has no further action. If SIGCONT is held, we
* continue the process and leave the signal in
* p_siglist. If the process catches SIGCONT, let it
* siglist. If the process catches SIGCONT, let it
* handle the signal itself. If it isn't waiting on
* an event, it goes back to run state.
* Otherwise, process goes back to sleep state.
@ -1425,7 +1516,7 @@ psignal(p, sig)
p->p_flag &= ~P_STOPPED_SIG;
p->p_flag |= P_CONTINUED;
if (action == SIG_DFL) {
SIGDELSET(p->p_siglist, sig);
SIGDELSET(*siglist, sig);
} else if (action == SIG_CATCH) {
/*
* The process wants to catch it so it needs
@ -1455,7 +1546,7 @@ psignal(p, sig)
* Just make sure the signal STOP bit set.
*/
p->p_flag |= P_STOPPED_SIG;
SIGDELSET(p->p_siglist, sig);
SIGDELSET(*siglist, sig);
goto out;
}
@ -1468,13 +1559,11 @@ psignal(p, sig)
* It may run a bit until it hits a thread_suspend_check().
*/
mtx_lock_spin(&sched_lock);
FOREACH_THREAD_IN_PROC(p, td) {
if (TD_ON_SLEEPQ(td) && (td->td_flags & TDF_SINTR)) {
if (td->td_flags & TDF_CVWAITQ)
cv_abort(td);
else
abortsleep(td);
}
if (TD_ON_SLEEPQ(td) && (td->td_flags & TDF_SINTR)) {
if (td->td_flags & TDF_CVWAITQ)
cv_abort(td);
else
abortsleep(td);
}
mtx_unlock_spin(&sched_lock);
goto out;
@ -1488,8 +1577,7 @@ psignal(p, sig)
if ((p->p_flag & P_TRACED) || (action != SIG_DFL) ||
!(prop & SA_STOP)) {
mtx_lock_spin(&sched_lock);
FOREACH_THREAD_IN_PROC(p, td)
tdsignal(td, sig, action);
tdsigwakeup(td, sig, action);
mtx_unlock_spin(&sched_lock);
goto out;
}
@ -1499,14 +1587,17 @@ psignal(p, sig)
p->p_flag |= P_STOPPED_SIG;
p->p_xstat = sig;
mtx_lock_spin(&sched_lock);
FOREACH_THREAD_IN_PROC(p, td) {
if (TD_IS_SLEEPING(td) &&
FOREACH_THREAD_IN_PROC(p, td0) {
if (TD_IS_SLEEPING(td0) &&
(td->td_flags & TDF_SINTR))
thread_suspend_one(td);
thread_suspend_one(td0);
}
thread_stopped(p);
if (p->p_numthreads == p->p_suspcount)
if (p->p_numthreads == p->p_suspcount) {
SIGDELSET(p->p_siglist, p->p_xstat);
FOREACH_THREAD_IN_PROC(p, td0)
SIGDELSET(td0->td_siglist, p->p_xstat);
}
mtx_unlock_spin(&sched_lock);
goto out;
}
@ -1515,7 +1606,7 @@ psignal(p, sig)
/* NOTREACHED */
} else {
/* Not in "NORMAL" state. discard the signal. */
SIGDELSET(p->p_siglist, sig);
SIGDELSET(*siglist, sig);
goto out;
}
@ -1526,8 +1617,7 @@ psignal(p, sig)
runfast:
mtx_lock_spin(&sched_lock);
FOREACH_THREAD_IN_PROC(p, td)
tdsignal(td, sig, action);
tdsigwakeup(td, sig, action);
thread_unsuspend(p);
mtx_unlock_spin(&sched_lock);
out:
@ -1541,7 +1631,7 @@ psignal(p, sig)
* out of any sleep it may be in etc.
*/
static void
tdsignal(struct thread *td, int sig, sig_t action)
tdsigwakeup(struct thread *td, int sig, sig_t action)
{
struct proc *p = td->td_proc;
register int prop;
@ -1591,6 +1681,11 @@ tdsignal(struct thread *td, int sig, sig_t action)
*/
if ((prop & SA_CONT) && action == SIG_DFL) {
SIGDELSET(p->p_siglist, sig);
/*
* It may be on either list in this state.
* Remove from both for now.
*/
SIGDELSET(td->td_siglist, sig);
return;
}
@ -1637,7 +1732,7 @@ issignal(td)
struct thread *td;
{
struct proc *p;
sigset_t mask;
sigset_t sigpending;
register int sig, prop;
p = td->td_proc;
@ -1647,13 +1742,14 @@ issignal(td)
for (;;) {
int traced = (p->p_flag & P_TRACED) || (p->p_stops & S_SIG);
mask = p->p_siglist;
SIGSETNAND(mask, p->p_sigmask);
sigpending = td->td_siglist;
SIGSETNAND(sigpending, td->td_sigmask);
if (p->p_flag & P_PPWAIT)
SIG_STOPSIGMASK(mask);
if (SIGISEMPTY(mask)) /* no signal to send */
SIG_STOPSIGMASK(sigpending);
if (SIGISEMPTY(sigpending)) /* no signal to send */
return (0);
sig = sig_ffs(&mask);
sig = sig_ffs(&sigpending);
prop = sigprop(sig);
_STOPEVENT(p, S_SIG, sig);
@ -1663,7 +1759,7 @@ issignal(td)
* only if P_TRACED was on when they were posted.
*/
if (SIGISMEMBER(p->p_sigignore, sig) && (traced == 0)) {
SIGDELSET(p->p_siglist, sig);
SIGDELSET(td->td_siglist, sig);
continue;
}
if (p->p_flag & P_TRACED && (p->p_flag & P_PPWAIT) == 0) {
@ -1698,19 +1794,19 @@ issignal(td)
* then it will leave it in p->p_xstat;
* otherwise we just look for signals again.
*/
SIGDELSET(p->p_siglist, sig); /* clear old signal */
SIGDELSET(td->td_siglist, sig); /* clear old signal */
sig = p->p_xstat;
if (sig == 0)
continue;
/*
* Put the new signal into p_siglist. If the
* Put the new signal into td_siglist. If the
* signal is being masked, look for other signals.
*/
SIGADDSET(p->p_siglist, sig);
if (SIGISMEMBER(p->p_sigmask, sig))
SIGADDSET(td->td_siglist, sig);
if (SIGISMEMBER(td->td_sigmask, sig))
continue;
signotify(p);
signotify(td);
}
/*
@ -1788,7 +1884,7 @@ issignal(td)
*/
return (sig);
}
SIGDELSET(p->p_siglist, sig); /* take the signal! */
SIGDELSET(td->td_siglist, sig); /* take the signal! */
}
/* NOTREACHED */
}
@ -1852,12 +1948,12 @@ postsig(sig)
PROC_LOCK_ASSERT(p, MA_OWNED);
ps = p->p_sigacts;
SIGDELSET(p->p_siglist, sig);
SIGDELSET(td->td_siglist, sig);
action = ps->ps_sigact[_SIG_IDX(sig)];
#ifdef KTRACE
if (KTRPOINT(td, KTR_PSIG))
ktrpsig(sig, action, p->p_flag & P_OLDMASK ?
&p->p_oldsigmask : &p->p_sigmask, 0);
ktrpsig(sig, action, td->td_flags & TDF_OLDMASK ?
&td->td_oldsigmask : &td->td_sigmask, 0);
#endif
_STOPEVENT(p, S_SIG, sig);
@ -1872,7 +1968,7 @@ postsig(sig)
/*
* If we get here, the signal must be caught.
*/
KASSERT(action != SIG_IGN && !SIGISMEMBER(p->p_sigmask, sig),
KASSERT(action != SIG_IGN && !SIGISMEMBER(td->td_sigmask, sig),
("postsig action"));
/*
* Set the new mask value and also defer further
@ -1883,15 +1979,17 @@ postsig(sig)
* mask from before the sigsuspend is what we want
* restored after the signal processing is completed.
*/
if (p->p_flag & P_OLDMASK) {
returnmask = p->p_oldsigmask;
p->p_flag &= ~P_OLDMASK;
mtx_lock_spin(&sched_lock);
if (td->td_flags & TDF_OLDMASK) {
returnmask = td->td_oldsigmask;
td->td_flags &= ~TDF_OLDMASK;
} else
returnmask = p->p_sigmask;
returnmask = td->td_sigmask;
mtx_unlock_spin(&sched_lock);
SIGSETOR(p->p_sigmask, ps->ps_catchmask[_SIG_IDX(sig)]);
SIGSETOR(td->td_sigmask, ps->ps_catchmask[_SIG_IDX(sig)]);
if (!SIGISMEMBER(ps->ps_signodefer, sig))
SIGADDSET(p->p_sigmask, sig);
SIGADDSET(td->td_sigmask, sig);
if (SIGISMEMBER(ps->ps_sigreset, sig)) {
/*

View File

@ -496,8 +496,10 @@ kse_release(struct thread *td, struct kse_release_args *uap)
mtx_lock_spin(&sched_lock);
/* Change OURSELF to become an upcall. */
td->td_flags = TDF_UPCALLING;
#if 0 /* XXX This shouldn't be necessary */
if (p->p_sflag & PS_NEEDSIGCHK)
td->td_flags |= TDF_ASTPENDING;
#endif
mtx_unlock_spin(&sched_lock);
PROC_LOCK(p);
while ((td->td_upcall->ku_flags & KUF_DOUPCALL) == 0 &&
@ -744,7 +746,7 @@ thread_getcontext(struct thread *td, ucontext_t *uc)
#ifdef __i386__
get_mcontext(td, &uc->uc_mcontext);
#endif
uc->uc_sigmask = td->td_proc->p_sigmask;
uc->uc_sigmask = td->td_sigmask;
}
/*
@ -769,7 +771,7 @@ thread_setcontext(struct thread *td, ucontext_t *uc)
if (ret == 0) {
SIG_CANTMASK(uc->uc_sigmask);
PROC_LOCK(td->td_proc);
td->td_proc->p_sigmask = uc->uc_sigmask;
td->td_sigmask = uc->uc_sigmask;
PROC_UNLOCK(td->td_proc);
}
return (ret);
@ -1247,6 +1249,7 @@ thread_exit(void)
} else {
PROC_UNLOCK(p);
}
/* XXX Shouldn't cpu_throw() here. */
cpu_throw();
/* NOTREACHED */
}
@ -1428,8 +1431,10 @@ thread_schedule_upcall(struct thread *td, struct kse_upcall *ku)
ku->ku_owner = td2;
td2->td_upcall = ku;
td2->td_flags = TDF_UPCALLING;
#if 0 /* XXX This shouldn't be necessary */
if (td->td_proc->p_sflag & PS_NEEDSIGCHK)
td2->td_flags |= TDF_ASTPENDING;
#endif
td2->td_kse = NULL;
td2->td_state = TDS_CAN_RUN;
td2->td_inhibitors = 0;
@ -1593,6 +1598,7 @@ thread_userret(struct thread *td, struct trapframe *frame)
p = td->td_proc;
kg = td->td_ksegrp;
/* Nothing to do with non-threaded group/process */
if (td->td_ksegrp->kg_numupcalls == 0)
return (0);
@ -1621,12 +1627,12 @@ thread_userret(struct thread *td, struct trapframe *frame)
if (TD_CAN_UNBIND(td)) {
mtx_lock_spin(&sched_lock);
td->td_flags &= ~TDF_CAN_UNBIND;
mtx_unlock_spin(&sched_lock);
ku = td->td_upcall;
if ((p->p_sflag & PS_NEEDSIGCHK) == 0 &&
if ((td->td_flags & TDF_NEEDSIGCHK) == 0 &&
(kg->kg_completed == NULL) &&
(ku->ku_flags & KUF_DOUPCALL) == 0 &&
(kg->kg_upquantum && ticks >= kg->kg_nextupcall)) {
mtx_unlock_spin(&sched_lock);
thread_update_usr_ticks(td, 0);
nanotime(&ts);
error = copyout(&ts,
@ -1637,6 +1643,7 @@ thread_userret(struct thread *td, struct trapframe *frame)
goto out;
return (0);
}
mtx_unlock_spin(&sched_lock);
error = thread_export_context(td);
if (error) {
/*

View File

@ -123,8 +123,8 @@ forward_signal(struct thread *td)
int id;
/*
* signotify() has already set TDF_ASTPENDING and PS_NEEDSIGCHECK on
* this process, so all we need to do is poke it if it is currently
* signotify() has already set TDF_ASTPENDING and TDF_NEEDSIGCHECK on
* this thread, so all we need to do is poke it if it is currently
* executing so that it executes ast().
*/
mtx_assert(&sched_lock, MA_OWNED);

View File

@ -81,7 +81,7 @@ userret(td, frame, oticks)
mtx_lock(&Giant);
PROC_LOCK(p);
mtx_lock_spin(&sched_lock);
if (SIGPENDING(p) && ((p->p_sflag & PS_NEEDSIGCHK) == 0 ||
if (SIGPENDING(td) && ((td->td_flags & TDF_NEEDSIGCHK) == 0 ||
(td->td_flags & TDF_ASTPENDING) == 0))
printf("failed to set signal flags properly for ast()\n");
mtx_unlock_spin(&sched_lock);
@ -174,11 +174,12 @@ ast(struct trapframe *framep)
sticks = td->td_sticks;
flags = td->td_flags;
sflag = p->p_sflag;
p->p_sflag &= ~(PS_ALRMPEND | PS_NEEDSIGCHK | PS_PROFPEND | PS_XCPU);
p->p_sflag &= ~(PS_ALRMPEND | PS_PROFPEND | PS_XCPU);
#ifdef MAC
p->p_sflag &= ~PS_MACPEND;
#endif
td->td_flags &= ~(TDF_ASTPENDING | TDF_NEEDRESCHED | TDF_OWEUPC);
td->td_flags &= ~(TDF_ASTPENDING | TDF_NEEDSIGCHK |
TDF_NEEDRESCHED | TDF_OWEUPC);
cnt.v_soft++;
prticks = 0;
if (flags & TDF_OWEUPC && sflag & PS_PROFIL) {
@ -243,7 +244,7 @@ ast(struct trapframe *framep)
mi_switch();
mtx_unlock_spin(&sched_lock);
}
if (sflag & PS_NEEDSIGCHK) {
if (flags & TDF_NEEDSIGCHK) {
int sigs;
sigs = 0;

View File

@ -777,7 +777,7 @@ ttioctl(struct tty *tp, u_long cmd, void *data, int flag)
PROC_LOCK(p);
while (isbackground(p, tp) && !(p->p_flag & P_PPWAIT) &&
!SIGISMEMBER(p->p_sigignore, SIGTTOU) &&
!SIGISMEMBER(p->p_sigmask, SIGTTOU)) {
!SIGISMEMBER(td->td_sigmask, SIGTTOU)) {
pgrp = p->p_pgrp;
PROC_UNLOCK(p);
if (pgrp->pg_jobc == 0) {
@ -1571,13 +1571,16 @@ ttread(struct tty *tp, struct uio *uio, int flag)
int c;
tcflag_t lflag;
cc_t *cc = tp->t_cc;
struct proc *p = curproc;
struct thread *td;
struct proc *p;
int s, first, error = 0;
int has_stime = 0, last_cc = 0;
long slp = 0; /* XXX this should be renamed `timo'. */
struct timeval stime;
struct pgrp *pg;
td = curthread;
p = td->td_proc;
loop:
s = spltty();
lflag = tp->t_lflag;
@ -1599,7 +1602,7 @@ ttread(struct tty *tp, struct uio *uio, int flag)
sx_slock(&proctree_lock);
PROC_LOCK(p);
if (SIGISMEMBER(p->p_sigignore, SIGTTIN) ||
SIGISMEMBER(p->p_sigmask, SIGTTIN) ||
SIGISMEMBER(td->td_sigmask, SIGTTIN) ||
(p->p_flag & P_PPWAIT) || p->p_pgrp->pg_jobc == 0) {
PROC_UNLOCK(p);
sx_sunlock(&proctree_lock);
@ -1847,15 +1850,16 @@ ttycheckoutq(struct tty *tp, int wait)
{
int hiwat, s;
sigset_t oldmask;
struct proc *p = curproc;
struct thread *td;
td = curthread;
hiwat = tp->t_ohiwat;
SIGEMPTYSET(oldmask);
s = spltty();
if (wait) {
PROC_LOCK(p);
oldmask = p->p_siglist;
PROC_UNLOCK(p);
PROC_LOCK(td->td_proc);
oldmask = td->td_siglist;
PROC_UNLOCK(td->td_proc);
}
if (tp->t_outq.c_cc > hiwat + OBUFSIZ + 100)
while (tp->t_outq.c_cc > hiwat) {
@ -1866,13 +1870,13 @@ ttycheckoutq(struct tty *tp, int wait)
splx(s);
return (0);
}
PROC_LOCK(p);
if (!SIGSETEQ(p->p_siglist, oldmask)) {
PROC_UNLOCK(p);
PROC_LOCK(td->td_proc);
if (!SIGSETEQ(td->td_siglist, oldmask)) {
PROC_UNLOCK(td->td_proc);
splx(s);
return (0);
}
PROC_UNLOCK(p);
PROC_UNLOCK(td->td_proc);
SET(tp->t_state, TS_SO_OLOWAT);
tsleep(TSA_OLOWAT(tp), PZERO - 1, "ttoutq", hz);
}
@ -1888,6 +1892,7 @@ ttwrite(struct tty *tp, struct uio *uio, int flag)
{
char *cp = NULL;
int cc, ce;
struct thread *td;
struct proc *p;
int i, hiwat, cnt, error, s;
char obuf[OBUFSIZ];
@ -1896,6 +1901,8 @@ ttwrite(struct tty *tp, struct uio *uio, int flag)
cnt = uio->uio_resid;
error = 0;
cc = 0;
td = curthread;
p = td->td_proc;
loop:
s = spltty();
if (ISSET(tp->t_state, TS_ZOMBIE)) {
@ -1921,13 +1928,12 @@ ttwrite(struct tty *tp, struct uio *uio, int flag)
/*
* Hang the process if it's in the background.
*/
p = curproc;
sx_slock(&proctree_lock);
PROC_LOCK(p);
if (isbackground(p, tp) &&
ISSET(tp->t_lflag, TOSTOP) && !(p->p_flag & P_PPWAIT) &&
!SIGISMEMBER(p->p_sigignore, SIGTTOU) &&
!SIGISMEMBER(p->p_sigmask, SIGTTOU)) {
!SIGISMEMBER(td->td_sigmask, SIGTTOU)) {
if (p->p_pgrp->pg_jobc == 0) {
PROC_UNLOCK(p);
sx_sunlock(&proctree_lock);

View File

@ -236,7 +236,7 @@ ptsread(dev, uio, flag)
sx_slock(&proctree_lock);
PROC_LOCK(p);
if (SIGISMEMBER(p->p_sigignore, SIGTTIN) ||
SIGISMEMBER(p->p_sigmask, SIGTTIN) ||
SIGISMEMBER(td->td_sigmask, SIGTTIN) ||
p->p_pgrp->pg_jobc == 0 || p->p_flag & P_PPWAIT) {
PROC_UNLOCK(p);
sx_sunlock(&proctree_lock);

View File

@ -86,9 +86,10 @@ ncp_chkintr(struct ncp_conn *conn, struct thread *td)
p = td->td_proc;
PROC_LOCK(p);
tmpset = p->p_siglist;
SIGSETNAND(tmpset, p->p_sigmask);
SIGSETOR(tmpset, td->td_siglist);
SIGSETNAND(tmpset, td->td_sigmask);
SIGSETNAND(tmpset, p->p_sigignore);
if (SIGNOTEMPTY(p->p_siglist) && NCP_SIGMASK(tmpset)) {
if (SIGNOTEMPTY(td->td_siglist) && NCP_SIGMASK(tmpset)) {
PROC_UNLOCK(p);
return EINTR;
}

View File

@ -356,7 +356,7 @@ smb_iod_recvall(struct smbiod *iod)
*/
SMB_IOD_RQLOCK(iod);
TAILQ_FOREACH(rqp, &iod->iod_rqlist, sr_link) {
if (smb_proc_intr(rqp->sr_cred->scr_td->td_proc)) {
if (smb_td_intr(rqp->sr_cred->scr_td)) {
smb_iod_rqprocessed(rqp, EINTR);
}
}

View File

@ -184,7 +184,7 @@ smb_rq_enqueue(struct smb_rq *rqp)
if (ssp->ss_flags & SMBS_RECONNECTING) {
msleep(&ssp->ss_vcgenid, SMBS_ST_LOCKPTR(ssp),
PWAIT | PDROP, "90trcn", hz);
if (smb_proc_intr(rqp->sr_cred->scr_td->td_proc))
if (smb_td_intr(rqp->sr_cred->scr_td))
return EINTR;
continue;
}
@ -248,11 +248,9 @@ smb_rq_bend(struct smb_rq *rqp)
int
smb_rq_intr(struct smb_rq *rqp)
{
struct proc *p = rqp->sr_cred->scr_td->td_proc;
if (rqp->sr_flags & SMBR_INTR)
return EINTR;
return smb_proc_intr(p);
return smb_td_intr(rqp->sr_cred->scr_td);
}
int

View File

@ -69,17 +69,21 @@ smb_makescred(struct smb_cred *scred, struct thread *td, struct ucred *cred)
}
int
smb_proc_intr(struct proc *p)
smb_td_intr(struct thread *td)
{
struct proc *p;
sigset_t tmpset;
if (p == NULL)
if (td == NULL)
return 0;
p = td->td_proc;
PROC_LOCK(p);
tmpset = p->p_siglist;
SIGSETNAND(tmpset, p->p_sigmask);
SIGSETOR(tmpset, td->td_siglist);
SIGSETNAND(tmpset, td->td_sigmask);
SIGSETNAND(tmpset, p->p_sigignore);
if (SIGNOTEMPTY(p->p_siglist) && SMB_SIGMASK(tmpset)) {
if (SIGNOTEMPTY(td->td_siglist) && SMB_SIGMASK(tmpset)) {
PROC_UNLOCK(p);
return EINTR;
}

View File

@ -140,7 +140,7 @@ struct smb_vc;
struct smb_rq;
void smb_makescred(struct smb_cred *scred, struct thread *td, struct ucred *cred);
int smb_proc_intr(struct proc *);
int smb_td_intr(struct thread *);
char *smb_strdup(const char *s);
void *smb_memdup(const void *umem, int len);
char *smb_strdupin(char *s, int maxlen);

View File

@ -1238,7 +1238,7 @@ nfs_sigintr(struct nfsmount *nmp, struct nfsreq *rep, struct thread *td)
p = td->td_proc;
PROC_LOCK(p);
tmpset = p->p_siglist;
SIGSETNAND(tmpset, p->p_sigmask);
SIGSETNAND(tmpset, td->td_sigmask);
SIGSETNAND(tmpset, p->p_sigignore);
if (SIGNOTEMPTY(p->p_siglist) && NFSINT_SIGMASK(tmpset)) {
PROC_UNLOCK(p);

View File

@ -771,9 +771,9 @@ osigreturn(td, uap)
else
p->p_sigstk.ss_flags &= ~SS_ONSTACK;
#endif
SIGSETOLD(p->p_sigmask, scp->sc_mask);
SIG_CANTMASK(p->p_sigmask);
signotify(p);
SIGSETOLD(td->td_sigmask, scp->sc_mask);
SIG_CANTMASK(td->td_sigmask);
signotify(td);
PROC_UNLOCK(p);
return (EJUSTRETURN);
}
@ -879,9 +879,9 @@ freebsd4_sigreturn(td, uap)
p->p_sigstk.ss_flags &= ~SS_ONSTACK;
#endif
p->p_sigmask = ucp->uc_sigmask;
SIG_CANTMASK(p->p_sigmask);
signotify(p);
td->td_sigmask = ucp->uc_sigmask;
SIG_CANTMASK(td->td_sigmask);
signotify(td);
PROC_UNLOCK(p);
return (EJUSTRETURN);
}
@ -989,9 +989,9 @@ sigreturn(td, uap)
p->p_sigstk.ss_flags &= ~SS_ONSTACK;
#endif
p->p_sigmask = ucp->uc_sigmask;
SIG_CANTMASK(p->p_sigmask);
signotify(p);
td->td_sigmask = ucp->uc_sigmask;
SIG_CANTMASK(td->td_sigmask);
signotify(td);
PROC_UNLOCK(p);
return (EJUSTRETURN);
}

View File

@ -771,9 +771,9 @@ osigreturn(td, uap)
else
p->p_sigstk.ss_flags &= ~SS_ONSTACK;
#endif
SIGSETOLD(p->p_sigmask, scp->sc_mask);
SIG_CANTMASK(p->p_sigmask);
signotify(p);
SIGSETOLD(td->td_sigmask, scp->sc_mask);
SIG_CANTMASK(td->td_sigmask);
signotify(td);
PROC_UNLOCK(p);
return (EJUSTRETURN);
}
@ -879,9 +879,9 @@ freebsd4_sigreturn(td, uap)
p->p_sigstk.ss_flags &= ~SS_ONSTACK;
#endif
p->p_sigmask = ucp->uc_sigmask;
SIG_CANTMASK(p->p_sigmask);
signotify(p);
td->td_sigmask = ucp->uc_sigmask;
SIG_CANTMASK(td->td_sigmask);
signotify(td);
PROC_UNLOCK(p);
return (EJUSTRETURN);
}
@ -989,9 +989,9 @@ sigreturn(td, uap)
p->p_sigstk.ss_flags &= ~SS_ONSTACK;
#endif
p->p_sigmask = ucp->uc_sigmask;
SIG_CANTMASK(p->p_sigmask);
signotify(p);
td->td_sigmask = ucp->uc_sigmask;
SIG_CANTMASK(td->td_sigmask);
signotify(td);
PROC_UNLOCK(p);
return (EJUSTRETURN);
}

View File

@ -538,9 +538,9 @@ sigreturn(struct thread *td, struct sigreturn_args *uap)
p = td->td_proc;
PROC_LOCK(p);
p->p_sigmask = uc.uc_sigmask;
SIG_CANTMASK(p->p_sigmask);
signotify(p);
td->td_sigmask = uc.uc_sigmask;
SIG_CANTMASK(td->td_sigmask);
signotify(td);
PROC_UNLOCK(p);
/*

View File

@ -538,9 +538,9 @@ sigreturn(struct thread *td, struct sigreturn_args *uap)
p = td->td_proc;
PROC_LOCK(p);
p->p_sigmask = uc.uc_sigmask;
SIG_CANTMASK(p->p_sigmask);
signotify(p);
td->td_sigmask = uc.uc_sigmask;
SIG_CANTMASK(td->td_sigmask);
signotify(td);
PROC_UNLOCK(p);
/*

View File

@ -492,9 +492,9 @@ sigreturn(struct thread *td, struct sigreturn_args *uap)
bcopy(mc, tf, sizeof(*tf));
PROC_LOCK(p);
p->p_sigmask = uc.uc_sigmask;
SIG_CANTMASK(p->p_sigmask);
signotify(p);
td->td_sigmask = uc.uc_sigmask;
SIG_CANTMASK(td->td_sigmask);
signotify(td);
PROC_UNLOCK(p);
CTR4(KTR_SIG, "sigreturn: return td=%p pc=%#lx sp=%#lx tstate=%#lx",

View File

@ -191,10 +191,10 @@ __sigseteq(sigset_t *set1, sigset_t *set2)
#ifdef _KERNEL
/* Return nonzero if process p has an unmasked pending signal. */
#define SIGPENDING(p) \
(!SIGISEMPTY((p)->p_siglist) && \
(!sigsetmasked(&(p)->p_siglist, &(p)->p_sigmask) || \
(p)->p_flag & P_TRACED))
#define SIGPENDING(td) \
(!SIGISEMPTY((td)->td_siglist) && \
(!sigsetmasked(&(td)->td_siglist, &(td)->td_sigmask) || \
(td)->td_proc->p_flag & P_TRACED))
/*
* Return the value of the pseudo-expression ((*set & ~*mask) != 0). This
@ -244,10 +244,14 @@ void pgsigio(struct sigio **, int signum, int checkctty);
void pgsignal(struct pgrp *pgrp, int sig, int checkctty);
void postsig(int sig);
void psignal(struct proc *p, int sig);
void tdsignal(struct thread *td, int sig);
void sigexit(struct thread *td, int signum) __dead2;
void siginit(struct proc *p);
void signotify(struct proc *p);
void signotify(struct thread *td);
void trapsignal(struct thread *td, int sig, u_long code);
int do_sigprocmask(struct thread *td, int how,
sigset_t *set, sigset_t *oset, int old);
int sig_ffs(sigset_t *set);
/*
* Machine-dependent functions: