diff options
author | mini <mini@FreeBSD.org> | 2003-02-17 10:05:18 +0000 |
---|---|---|
committer | mini <mini@FreeBSD.org> | 2003-02-17 10:05:18 +0000 |
commit | f410bbff9bdafda36fadec4dfcd193618bf28eaf (patch) | |
tree | c24155922d6dce25dde63eab941dbc318206ebdf /lib/libpthread/thread/thr_init.c | |
parent | 6ebeaa8ec8a84c0fe2ebf0392ae3386ba9840a81 (diff) | |
download | FreeBSD-src-f410bbff9bdafda36fadec4dfcd193618bf28eaf.zip FreeBSD-src-f410bbff9bdafda36fadec4dfcd193618bf28eaf.tar.gz |
Deliver signals posted via an upcall to the appropriate thread.
Diffstat (limited to 'lib/libpthread/thread/thr_init.c')
-rw-r--r-- | lib/libpthread/thread/thr_init.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/lib/libpthread/thread/thr_init.c b/lib/libpthread/thread/thr_init.c index 9f2f894..8e19924 100644 --- a/lib/libpthread/thread/thr_init.c +++ b/lib/libpthread/thread/thr_init.c @@ -162,6 +162,12 @@ _thread_init(void) int sched_stack_size; /* Size of scheduler stack. */ struct clockinfo clockinfo; + struct sigaction act; + + /* Check if this function has already been called: */ + if (_thread_initial) + /* Only initialise the threaded application once. */ + return; _pthread_page_size = getpagesize(); _pthread_guard_default = getpagesize(); @@ -338,6 +344,31 @@ _thread_init(void) TAILQ_INSERT_HEAD(&_thread_list, _thread_initial, tle); _set_curthread(_thread_initial); + /* Clear the pending signals for the process. */ + sigemptyset(&_thread_sigpending); + + /* Enter a loop to get the existing signal status: */ + for (i = 1; i < NSIG; i++) { + /* Check for signals which cannot be trapped. */ + if (i == SIGKILL || i == SIGSTOP) + continue; + + /* Get the signal handler details. */ + if (__sys_sigaction(i, NULL, + &_thread_sigact[i - 1]) != 0) + PANIC("Cannot read signal handler info"); + } + + /* Register SIGCHLD (needed for wait(2)). */ + sigfillset(&act.sa_mask); + act.sa_handler = (void (*) ()) _thread_sig_handler; + act.sa_flags = SA_SIGINFO | SA_RESTART; + if (__sys_sigaction(SIGCHLD, &act, NULL) != 0) + PANIC("Can't initialize signal handler"); + + /* Get the process signal mask. */ + __sys_sigprocmask(SIG_SETMASK, NULL, &_thread_sigmask); + /* Get the kernel clockrate: */ mib[0] = CTL_KERN; mib[1] = KERN_CLOCKRATE; |