diff options
Diffstat (limited to 'lib/libpthread/thread/thr_init.c')
-rw-r--r-- | lib/libpthread/thread/thr_init.c | 55 |
1 files changed, 22 insertions, 33 deletions
diff --git a/lib/libpthread/thread/thr_init.c b/lib/libpthread/thread/thr_init.c index 78967f4..c267a2c 100644 --- a/lib/libpthread/thread/thr_init.c +++ b/lib/libpthread/thread/thr_init.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>. + * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au> * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -44,7 +44,6 @@ #include <machine/reg.h> #include <pthread.h> #include "pthread_private.h" -extern int _thread_autoinit_dummy_decl; #ifdef GCC_2_8_MADE_THREAD_AWARE typedef void *** (*dynamic_handler_allocator)(); @@ -80,8 +79,6 @@ _thread_init(void) int flags; int i; struct sigaction act; - /* Ensure that the auto-initialization routine is linked in: */ - _thread_autoinit_dummy_decl = 1; /* Check if this function has already been called: */ if (_thread_initial) @@ -96,7 +93,7 @@ _thread_init(void) /* * Create a pipe that is written to by the signal handler to prevent - * signals being missed in calls to _thread_sys_select: + * signals being missed in calls to _select: */ if (_thread_sys_pipe(_thread_kern_pipe) != 0) { /* Cannot create pipe, so abort: */ @@ -144,7 +141,6 @@ _thread_init(void) _thread_queue_init(&(_thread_initial->join_queue)); /* Initialise the rest of the fields: */ - _thread_initial->parent_thread = NULL; _thread_initial->specific_data = NULL; _thread_initial->cleanup = NULL; _thread_initial->queue = NULL; @@ -155,49 +151,42 @@ _thread_init(void) _thread_link_list = _thread_initial; _thread_run = _thread_initial; - /* 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) { - } - /* Get the signal handler details: */ - else if (_thread_sys_sigaction(i, NULL, &act) != 0) { - /* - * Abort this process if signal - * initialisation fails: - */ - PANIC("Cannot read signal handler info"); - } - /* Set the signal handler for the initial thread: */ - else if (sigaction(i, &act, NULL) != 0) { - /* - * Abort this process if signal - * initialisation fails: - */ - PANIC("Cannot initialise signal handler for initial thread"); - } - } - /* Initialise the global signal action structure: */ sigfillset(&act.sa_mask); act.sa_handler = (void (*) ()) _thread_sig_handler; act.sa_flags = SA_RESTART; - /* Enter a loop to initialise the rest of the signals: */ + /* 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) { } - /* Initialise the signal for default handling: */ - else if (_thread_sys_sigaction(i, &act, NULL) != 0) { + + /* Get the signal handler details: */ + else if (_thread_sys_sigaction(i, NULL, + &_thread_sigact[i - 1]) != 0) { /* * Abort this process if signal * initialisation fails: */ - PANIC("Cannot initialise signal handler"); + PANIC("Cannot read signal handler info"); } } + /* + * Install the signal handler for the most important + * signals that the user-thread kernel needs. Actually + * SIGINFO isn't really needed, but it is nice to have. + */ + if (_thread_sys_sigaction(SIGVTALRM, &act, NULL) != 0 || + _thread_sys_sigaction(SIGINFO , &act, NULL) != 0 || + _thread_sys_sigaction(SIGCHLD , &act, NULL) != 0) { + /* + * Abort this process if signal initialisation fails: + */ + PANIC("Cannot initialise signal handler"); + } + /* Get the table size: */ if ((_thread_dtablesize = getdtablesize()) < 0) { /* |