summaryrefslogtreecommitdiff
path: root/lib/libpthread/thread/thr_kill.c
diff options
context:
space:
mode:
authorJohn Birrell <jb@FreeBSD.org>1998-09-30 06:27:31 +0000
committerJohn Birrell <jb@FreeBSD.org>1998-09-30 06:27:31 +0000
commit54059e9f3f0bf395e5a20208e87e21dd4eab8680 (patch)
tree17f1ae45633c6df6fba17dcc9b30eebf1176bf76 /lib/libpthread/thread/thr_kill.c
parent92ce833722f80de44bcc340f24019228565ee33f (diff)
Notes
Diffstat (limited to 'lib/libpthread/thread/thr_kill.c')
-rw-r--r--lib/libpthread/thread/thr_kill.c44
1 files changed, 37 insertions, 7 deletions
diff --git a/lib/libpthread/thread/thr_kill.c b/lib/libpthread/thread/thr_kill.c
index 98b3a2d39b90..292ba5caf8f2 100644
--- a/lib/libpthread/thread/thr_kill.c
+++ b/lib/libpthread/thread/thr_kill.c
@@ -46,18 +46,48 @@ pthread_kill(pthread_t pthread, int sig)
/* Invalid signal: */
ret = EINVAL;
+ /* Ignored signals get dropped on the floor. */
+ else if (_thread_sigact[sig - 1].sa_handler == SIG_IGN)
+ ret = 0;
+
/* Find the thread in the list of active threads: */
else if ((ret = _find_thread(pthread)) == 0) {
- if ((pthread->state == PS_SIGWAIT) &&
- sigismember(&pthread->sigmask, sig)) {
- /* Change the state of the thread to run: */
- PTHREAD_NEW_STATE(pthread,PS_RUNNING);
+ switch (pthread->state) {
+ case PS_SIGSUSPEND:
+ /*
+ * Only wake up the thread if the signal is unblocked
+ * and there is a handler installed for the signal.
+ */
+ if (!sigismember(&pthread->sigmask, sig) &&
+ _thread_sigact[sig - 1].sa_handler != SIG_DFL) {
+ /* Change the state of the thread to run: */
+ PTHREAD_NEW_STATE(pthread,PS_RUNNING);
+
+ /* Return the signal number: */
+ pthread->signo = sig;
+ }
+ /* Increment the pending signal count: */
+ sigaddset(&pthread->sigpend,sig);
+ break;
+
+ case PS_SIGWAIT:
+ /* Wake up the thread if the signal is blocked. */
+ if (sigismember(pthread->data.sigwait, sig)) {
+ /* Change the state of the thread to run: */
+ PTHREAD_NEW_STATE(pthread,PS_RUNNING);
+
+ /* Return the signal number: */
+ pthread->signo = sig;
+ } else
+ /* Increment the pending signal count. */
+ sigaddset(&pthread->sigpend,sig);
+ break;
- /* Return the signal number: */
- pthread->signo = sig;
- } else
+ default:
/* Increment the pending signal count: */
sigaddset(&pthread->sigpend,sig);
+ break;
+ }
}
/* Return the completion status: */