diff options
author | David Leonard <d@cvs.openbsd.org> | 1998-11-09 03:13:22 +0000 |
---|---|---|
committer | David Leonard <d@cvs.openbsd.org> | 1998-11-09 03:13:22 +0000 |
commit | ff47464de5e68e9c49fe312c953f54b2e90f546c (patch) | |
tree | 4ec0e7f13d619e1b5bf6abfd7125a4ec17569568 /lib/libpthread/uthread/uthread_kill.c | |
parent | 1b2b2c2386c6cc5ebffc769b8a39b80d47e4e0d0 (diff) |
sync with FreeBSD (rwlock, gc thread, man pages)
add (broken) mips md stuff
fix some const warnings
add sigaltstack() stub
another hash at getting shlib auto-init to work (mips/elf and i386/a.out)
Diffstat (limited to 'lib/libpthread/uthread/uthread_kill.c')
-rw-r--r-- | lib/libpthread/uthread/uthread_kill.c | 44 |
1 files changed, 37 insertions, 7 deletions
diff --git a/lib/libpthread/uthread/uthread_kill.c b/lib/libpthread/uthread/uthread_kill.c index 98b3a2d39b9..292ba5caf8f 100644 --- a/lib/libpthread/uthread/uthread_kill.c +++ b/lib/libpthread/uthread/uthread_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: */ |