Deleted Added
sdiff udiff text old ( 115080 ) new ( 115278 )
full compact
1/*
2 * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 15 unchanged lines hidden (view full) ---

24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 * SUCH DAMAGE.
31 *
32 * $FreeBSD: head/lib/libkse/thread/thr_sig.c 115080 2003-05-16 19:58:30Z deischen $
33 */
34#include <sys/param.h>
35#include <sys/types.h>
36#include <sys/signalvar.h>
37#include <signal.h>
38#include <errno.h>
39#include <fcntl.h>
40#include <unistd.h>

--- 105 unchanged lines hidden (view full) ---

146_thr_sig_dispatch(struct kse *curkse, int sig, siginfo_t *info)
147{
148 struct pthread *thread;
149
150 DBG_MSG(">>> _thr_sig_dispatch(%d)\n", sig);
151
152 /* Some signals need special handling: */
153 handle_special_signals(curkse, sig);
154
155 if ((thread = thr_sig_find(curkse, sig, info)) != NULL) {
156 /*
157 * Setup the target thread to receive the signal:
158 */
159 DBG_MSG("Got signal %d, selecting thread %p\n", sig, thread);
160 KSE_SCHED_LOCK(curkse, thread->kseg);
161 _thr_sig_add(thread, sig, info);
162 KSE_SCHED_UNLOCK(curkse, thread->kseg);
163 }
164}
165
166void
167_thr_sig_handler(int sig, siginfo_t *info, ucontext_t *ucp)
168{
169 void (*sigfunc)(int, siginfo_t *, void *);
170 struct kse *curkse;

--- 145 unchanged lines hidden (view full) ---

316 }
317 else if ((pthread->state == PS_DEAD) ||
318 (pthread->state == PS_DEADLOCK) ||
319 THR_IS_EXITING(pthread) || THR_IS_SUSPENDED(pthread))
320 ; /* Skip this thread. */
321 else if ((handler_installed != 0) &&
322 !sigismember(&pthread->tmbx.tm_context.uc_sigmask, sig)) {
323 if (pthread->state == PS_SIGSUSPEND) {
324 if (suspended_thread == NULL)
325 suspended_thread = pthread;
326 } else if (signaled_thread == NULL)
327 signaled_thread = pthread;
328 }
329 KSE_SCHED_UNLOCK(curkse, pthread->kseg);
330 }
331 KSE_LOCK_RELEASE(curkse, &_thread_list_lock);
332
333 /*
334 * Only perform wakeups and signal delivery if there is a
335 * custom handler installed:

--- 18 unchanged lines hidden (view full) ---

354 sizeof(*info));
355 }
356 KSE_LOCK_RELEASE(curkse, &_thread_signal_lock);
357 } else {
358 /*
359 * We only deliver the signal to one thread;
360 * give preference to the suspended thread:
361 */
362 if (suspended_thread != NULL)
363 pthread = suspended_thread;
364 else
365 pthread = signaled_thread;
366 return (pthread);
367 }
368 return (NULL);
369}
370
371static void
372build_siginfo(siginfo_t *info, int signo)

--- 518 unchanged lines hidden ---