aboutsummaryrefslogtreecommitdiff
path: root/lib/libpthread
diff options
context:
space:
mode:
authorJason Evans <jasone@FreeBSD.org>2000-08-01 21:19:09 +0000
committerJason Evans <jasone@FreeBSD.org>2000-08-01 21:19:09 +0000
commitb167c9a5c1e612daae9303c4deb630289cf6baf8 (patch)
treecb838ed55754e6e156ad137080c940bd99573d4e /lib/libpthread
parentd99672504fc443b4ef0761598d37c95496a5d1db (diff)
Notes
Diffstat (limited to 'lib/libpthread')
-rw-r--r--lib/libpthread/man/sem_post.33
-rw-r--r--lib/libpthread/thread/thr_sem.c7
2 files changed, 10 insertions, 0 deletions
diff --git a/lib/libpthread/man/sem_post.3 b/lib/libpthread/man/sem_post.3
index 906d86d87c2b9..34fef83c614d9 100644
--- a/lib/libpthread/man/sem_post.3
+++ b/lib/libpthread/man/sem_post.3
@@ -48,6 +48,9 @@ If there are threads blocked on the semaphore when
is called, then the highest priority thread that has been blocked the longest on
the semaphore will be allowed to return from
.Fn sem_wait .
+.Pp
+.Fn sem_post
+is signal-reentrant and may be called within signal handlers.
.Sh RETURN VALUES
If successful,
.Fn sem_post
diff --git a/lib/libpthread/thread/thr_sem.c b/lib/libpthread/thread/thr_sem.c
index 10dec5ed036fe..5a4757c5388ec 100644
--- a/lib/libpthread/thread/thr_sem.c
+++ b/lib/libpthread/thread/thr_sem.c
@@ -206,6 +206,12 @@ sem_post(sem_t *sem)
_SEM_CHECK_VALIDITY(sem);
+ /*
+ * sem_post() is required to be safe to call from within signal
+ * handlers. Thus, we must defer signals.
+ */
+ _thread_kern_sig_defer();
+
pthread_mutex_lock(&(*sem)->lock);
(*sem)->count++;
@@ -221,6 +227,7 @@ sem_post(sem_t *sem)
pthread_mutex_unlock(&(*sem)->lock);
+ _thread_kern_sig_defer();
retval = 0;
RETURN:
return retval;