summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authordavidxu <davidxu@FreeBSD.org>2003-07-04 07:49:06 +0000
committerdavidxu <davidxu@FreeBSD.org>2003-07-04 07:49:06 +0000
commit5a2adbe7093f3725f2d3c64092af848fb3880f9e (patch)
tree42198d85a28291b0a93d7bd6ae9fd694da4b2563 /lib
parentc8bcc1e2f7c3b27923bc5f5c7d62cefdcb9708d0 (diff)
downloadFreeBSD-src-5a2adbe7093f3725f2d3c64092af848fb3880f9e.zip
FreeBSD-src-5a2adbe7093f3725f2d3c64092af848fb3880f9e.tar.gz
Always check and restore sigaction previously set, also access user parameter
outside of lock.
Diffstat (limited to 'lib')
-rw-r--r--lib/libkse/thread/thr_sigwait.c11
-rw-r--r--lib/libpthread/thread/thr_sigwait.c11
2 files changed, 14 insertions, 8 deletions
diff --git a/lib/libkse/thread/thr_sigwait.c b/lib/libkse/thread/thr_sigwait.c
index 5389c8a..a2411310 100644
--- a/lib/libkse/thread/thr_sigwait.c
+++ b/lib/libkse/thread/thr_sigwait.c
@@ -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);
}
diff --git a/lib/libpthread/thread/thr_sigwait.c b/lib/libpthread/thread/thr_sigwait.c
index 5389c8a..a2411310 100644
--- a/lib/libpthread/thread/thr_sigwait.c
+++ b/lib/libpthread/thread/thr_sigwait.c
@@ -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);
}
OpenPOWER on IntegriCloud