1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-18 10:35:55 +00:00

Always check and restore sigaction previously set, also access user parameter

outside of lock.
This commit is contained in:
David Xu 2003-07-04 07:49:06 +00:00
parent 71cfaac0b0
commit dfde101719
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=117216
2 changed files with 14 additions and 8 deletions

View File

@ -113,11 +113,12 @@ lib_sigtimedwait(const sigset_t *set, siginfo_t *info,
if (SIGISMEMBER(waitset, i) &&
SIGISMEMBER(curthread->sigpend, i)) {
SIGDELSET(curthread->sigpend, i);
*info = curthread->siginfo[i - 1];
siginfo = curthread->siginfo[i - 1];
KSE_SCHED_UNLOCK(curthread->kse,
curthread->kseg);
_kse_critical_leave(crit);
return (i);
ret = i;
goto OUT;
}
}
curthread->timeout = 0;
@ -137,8 +138,6 @@ lib_sigtimedwait(const sigset_t *set, siginfo_t *info,
* status.
*/
if (siginfo.si_signo > 0) {
if (info)
*info = siginfo;
ret = siginfo.si_signo;
} else {
if (curthread->timeout)
@ -158,6 +157,7 @@ lib_sigtimedwait(const sigset_t *set, siginfo_t *info,
KSE_LOCK_ACQUIRE(curthread->kse, &_thread_signal_lock);
}
OUT:
/* Restore the sigactions: */
act.sa_handler = SIG_DFL;
for (i = 1; i <= _SIG_MAXSIG; i++) {
@ -174,6 +174,9 @@ lib_sigtimedwait(const sigset_t *set, siginfo_t *info,
KSE_LOCK_RELEASE(curthread->kse, &_thread_signal_lock);
_kse_critical_leave(crit);
if (ret > 0 && info != NULL)
*info = siginfo;
return (ret);
}

View File

@ -113,11 +113,12 @@ lib_sigtimedwait(const sigset_t *set, siginfo_t *info,
if (SIGISMEMBER(waitset, i) &&
SIGISMEMBER(curthread->sigpend, i)) {
SIGDELSET(curthread->sigpend, i);
*info = curthread->siginfo[i - 1];
siginfo = curthread->siginfo[i - 1];
KSE_SCHED_UNLOCK(curthread->kse,
curthread->kseg);
_kse_critical_leave(crit);
return (i);
ret = i;
goto OUT;
}
}
curthread->timeout = 0;
@ -137,8 +138,6 @@ lib_sigtimedwait(const sigset_t *set, siginfo_t *info,
* status.
*/
if (siginfo.si_signo > 0) {
if (info)
*info = siginfo;
ret = siginfo.si_signo;
} else {
if (curthread->timeout)
@ -158,6 +157,7 @@ lib_sigtimedwait(const sigset_t *set, siginfo_t *info,
KSE_LOCK_ACQUIRE(curthread->kse, &_thread_signal_lock);
}
OUT:
/* Restore the sigactions: */
act.sa_handler = SIG_DFL;
for (i = 1; i <= _SIG_MAXSIG; i++) {
@ -174,6 +174,9 @@ lib_sigtimedwait(const sigset_t *set, siginfo_t *info,
KSE_LOCK_RELEASE(curthread->kse, &_thread_signal_lock);
_kse_critical_leave(crit);
if (ret > 0 && info != NULL)
*info = siginfo;
return (ret);
}