Commit 531ff0be authored by Alexandre Julliard's avatar Alexandre Julliard

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

parent f3bf2a70
...@@ -53,7 +53,8 @@ extern NTSTATUS NTDLL_wait_for_multiple_objects( UINT count, const HANDLE *handl ...@@ -53,7 +53,8 @@ extern NTSTATUS NTDLL_wait_for_multiple_objects( UINT count, const HANDLE *handl
const LARGE_INTEGER *timeout, HANDLE signal_object ); const LARGE_INTEGER *timeout, HANDLE signal_object );
/* init routines */ /* 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 size_t get_signal_stack_total_size(void);
extern void version_init( const WCHAR *appname ); extern void version_init( const WCHAR *appname );
extern void debug_init(void); extern void debug_init(void);
......
...@@ -985,7 +985,7 @@ NTSTATUS server_init_process_done(void) ...@@ -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 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 * we set them up here. If we segfault between here and the server call
* something is very wrong... */ * something is very wrong... */
if (!SIGNAL_Init()) exit(1); signal_init_process();
/* Signal the parent process to continue */ /* Signal the parent process to continue */
SERVER_START_REQ( init_process_done ) SERVER_START_REQ( init_process_done )
......
...@@ -1533,12 +1533,10 @@ int __wine_set_signal_handler(unsigned int sig, wine_signal_handler wsh) ...@@ -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 #ifdef HAVE_SIGALTSTACK
stack_t ss; stack_t ss;
...@@ -1553,12 +1551,16 @@ BOOL SIGNAL_Init(void) ...@@ -1553,12 +1551,16 @@ BOOL SIGNAL_Init(void)
ss.ss_sp = get_signal_stack(); ss.ss_sp = get_signal_stack();
ss.ss_size = signal_stack_size; ss.ss_size = signal_stack_size;
ss.ss_flags = 0; ss.ss_flags = 0;
if (sigaltstack(&ss, NULL) == -1) if (sigaltstack(&ss, NULL) == -1) perror( "sigaltstack" );
{
perror( "sigaltstack" );
return FALSE;
}
#endif /* HAVE_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_mask = server_block_set;
sig_act.sa_flags = SA_SIGINFO | SA_RESTART; sig_act.sa_flags = SA_SIGINFO | SA_RESTART;
...@@ -1594,11 +1596,12 @@ BOOL SIGNAL_Init(void) ...@@ -1594,11 +1596,12 @@ BOOL SIGNAL_Init(void)
if (sigaction( SIGUSR2, &sig_act, NULL ) == -1) goto error; if (sigaction( SIGUSR2, &sig_act, NULL ) == -1) goto error;
#endif #endif
return TRUE; signal_init_thread();
return;
error: error:
perror("sigaction"); perror("sigaction");
return FALSE; exit(1);
} }
......
...@@ -648,9 +648,16 @@ int __wine_set_signal_handler(unsigned int sig, wine_signal_handler wsh) ...@@ -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( SIGINT, (void (*)())int_handler ) == -1) goto error;
if (set_handler( SIGFPE, (void (*)())fpe_handler ) == -1) goto error; if (set_handler( SIGFPE, (void (*)())fpe_handler ) == -1) goto error;
...@@ -665,12 +672,12 @@ BOOL SIGNAL_Init(void) ...@@ -665,12 +672,12 @@ BOOL SIGNAL_Init(void)
#ifdef SIGTRAP #ifdef SIGTRAP
if (set_handler( SIGTRAP, (void (*)())trap_handler ) == -1) goto error; if (set_handler( SIGTRAP, (void (*)())trap_handler ) == -1) goto error;
#endif #endif
signal_init_thread();
return TRUE; return;
error: error:
perror("sigaction"); perror("sigaction");
return FALSE; exit(1);
} }
......
...@@ -457,9 +457,16 @@ int __wine_set_signal_handler(unsigned int sig, wine_signal_handler wsh) ...@@ -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( SIGINT, (void (*)())int_handler ) == -1) goto error;
if (set_handler( SIGFPE, (void (*)())fpe_handler ) == -1) goto error; if (set_handler( SIGFPE, (void (*)())fpe_handler ) == -1) goto error;
...@@ -476,11 +483,12 @@ BOOL SIGNAL_Init(void) ...@@ -476,11 +483,12 @@ BOOL SIGNAL_Init(void)
this is correct, because that is what x86 does, or it is harmful this is correct, because that is what x86 does, or it is harmful
because it could obscure problems in user code */ because it could obscure problems in user code */
asm("ta 6"); /* 6 == ST_FIX_ALIGN defined in sys/trap.h */ asm("ta 6"); /* 6 == ST_FIX_ALIGN defined in sys/trap.h */
return TRUE; signal_init_thread();
return;
error: error:
perror("sigaction"); perror("sigaction");
return FALSE; exit(1);
} }
......
...@@ -481,9 +481,16 @@ int __wine_set_signal_handler(unsigned int sig, wine_signal_handler wsh) ...@@ -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( SIGINT, (void (*)())int_handler ) == -1) goto error;
if (set_handler( SIGFPE, (void (*)())fpe_handler ) == -1) goto error; if (set_handler( SIGFPE, (void (*)())fpe_handler ) == -1) goto error;
...@@ -498,11 +505,12 @@ BOOL SIGNAL_Init(void) ...@@ -498,11 +505,12 @@ BOOL SIGNAL_Init(void)
#ifdef SIGTRAP #ifdef SIGTRAP
if (set_handler( SIGTRAP, (void (*)())trap_handler ) == -1) goto error; if (set_handler( SIGTRAP, (void (*)())trap_handler ) == -1) goto error;
#endif #endif
return TRUE; signal_init_thread();
return;
error: error:
perror("sigaction"); perror("sigaction");
return FALSE; exit(1);
} }
......
...@@ -424,7 +424,7 @@ static void start_thread( struct wine_pthread_thread_info *info ) ...@@ -424,7 +424,7 @@ static void start_thread( struct wine_pthread_thread_info *info )
thread_data->debug_info = &debug_info; thread_data->debug_info = &debug_info;
pthread_functions.init_current_teb( info ); pthread_functions.init_current_teb( info );
SIGNAL_Init(); signal_init_thread();
server_init_thread( info->pid, info->tid, func ); server_init_thread( info->pid, info->tid, func );
pthread_functions.init_thread( info ); pthread_functions.init_thread( info );
virtual_alloc_thread_stack( info->stack_base, info->stack_size ); virtual_alloc_thread_stack( info->stack_base, info->stack_size );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment