ntdll: Split the signal setup into process-wide and thread-specific routines.

This commit is contained in:
Alexandre Julliard 2008-07-03 20:18:23 +02:00
parent f3bf2a7045
commit 531ff0be26
7 changed files with 54 additions and 27 deletions

View File

@ -53,7 +53,8 @@ extern NTSTATUS NTDLL_wait_for_multiple_objects( UINT count, const HANDLE *handl
const LARGE_INTEGER *timeout, HANDLE signal_object );
/* init routines */
extern BOOL SIGNAL_Init(void);
extern void signal_init_thread(void);
extern void signal_init_process(void);
extern size_t get_signal_stack_total_size(void);
extern void version_init( const WCHAR *appname );
extern void debug_init(void);

View File

@ -985,7 +985,7 @@ NTSTATUS server_init_process_done(void)
* We do need the handlers in place by the time the request is over, so
* we set them up here. If we segfault between here and the server call
* something is very wrong... */
if (!SIGNAL_Init()) exit(1);
signal_init_process();
/* Signal the parent process to continue */
SERVER_START_REQ( init_process_done )

View File

@ -1533,12 +1533,10 @@ int __wine_set_signal_handler(unsigned int sig, wine_signal_handler wsh)
/**********************************************************************
* SIGNAL_Init
* signal_init_thread
*/
BOOL SIGNAL_Init(void)
void signal_init_thread(void)
{
struct sigaction sig_act;
#ifdef HAVE_SIGALTSTACK
stack_t ss;
@ -1553,12 +1551,16 @@ BOOL SIGNAL_Init(void)
ss.ss_sp = get_signal_stack();
ss.ss_size = signal_stack_size;
ss.ss_flags = 0;
if (sigaltstack(&ss, NULL) == -1)
{
perror( "sigaltstack" );
return FALSE;
}
if (sigaltstack(&ss, NULL) == -1) perror( "sigaltstack" );
#endif /* HAVE_SIGALTSTACK */
}
/**********************************************************************
* signal_init_process
*/
void signal_init_process(void)
{
struct sigaction sig_act;
sig_act.sa_mask = server_block_set;
sig_act.sa_flags = SA_SIGINFO | SA_RESTART;
@ -1594,11 +1596,12 @@ BOOL SIGNAL_Init(void)
if (sigaction( SIGUSR2, &sig_act, NULL ) == -1) goto error;
#endif
return TRUE;
signal_init_thread();
return;
error:
perror("sigaction");
return FALSE;
exit(1);
}

View File

@ -648,9 +648,16 @@ int __wine_set_signal_handler(unsigned int sig, wine_signal_handler wsh)
/**********************************************************************
* SIGNAL_Init
* signal_init_thread
*/
BOOL SIGNAL_Init(void)
void signal_init_thread(void)
{
}
/**********************************************************************
* signal_init_process
*/
void signal_init_process(void)
{
if (set_handler( SIGINT, (void (*)())int_handler ) == -1) goto error;
if (set_handler( SIGFPE, (void (*)())fpe_handler ) == -1) goto error;
@ -665,12 +672,12 @@ BOOL SIGNAL_Init(void)
#ifdef SIGTRAP
if (set_handler( SIGTRAP, (void (*)())trap_handler ) == -1) goto error;
#endif
return TRUE;
signal_init_thread();
return;
error:
perror("sigaction");
return FALSE;
exit(1);
}

View File

@ -457,9 +457,16 @@ int __wine_set_signal_handler(unsigned int sig, wine_signal_handler wsh)
/**********************************************************************
* SIGNAL_Init
* signal_init_thread
*/
BOOL SIGNAL_Init(void)
void signal_init_thread(void)
{
}
/**********************************************************************
* signal_init_process
*/
void signal_init_process(void)
{
if (set_handler( SIGINT, (void (*)())int_handler ) == -1) goto error;
if (set_handler( SIGFPE, (void (*)())fpe_handler ) == -1) goto error;
@ -476,11 +483,12 @@ BOOL SIGNAL_Init(void)
this is correct, because that is what x86 does, or it is harmful
because it could obscure problems in user code */
asm("ta 6"); /* 6 == ST_FIX_ALIGN defined in sys/trap.h */
return TRUE;
signal_init_thread();
return;
error:
perror("sigaction");
return FALSE;
exit(1);
}

View File

@ -481,9 +481,16 @@ int __wine_set_signal_handler(unsigned int sig, wine_signal_handler wsh)
/**********************************************************************
* SIGNAL_Init
* signal_init_thread
*/
BOOL SIGNAL_Init(void)
void signal_init_thread(void)
{
}
/**********************************************************************
* signal_init_process
*/
void signal_init_process(void)
{
if (set_handler( SIGINT, (void (*)())int_handler ) == -1) goto error;
if (set_handler( SIGFPE, (void (*)())fpe_handler ) == -1) goto error;
@ -498,11 +505,12 @@ BOOL SIGNAL_Init(void)
#ifdef SIGTRAP
if (set_handler( SIGTRAP, (void (*)())trap_handler ) == -1) goto error;
#endif
return TRUE;
signal_init_thread();
return;
error:
perror("sigaction");
return FALSE;
exit(1);
}

View File

@ -424,7 +424,7 @@ static void start_thread( struct wine_pthread_thread_info *info )
thread_data->debug_info = &debug_info;
pthread_functions.init_current_teb( info );
SIGNAL_Init();
signal_init_thread();
server_init_thread( info->pid, info->tid, func );
pthread_functions.init_thread( info );
virtual_alloc_thread_stack( info->stack_base, info->stack_size );