Commit 6a26e3f7 authored by Alexandre Julliard's avatar Alexandre Julliard

Split signal blocking code out of SIGNAL_Reset into SIGNAL_Block.

Added SIGTERM handler.
parent bace7a11
...@@ -54,8 +54,6 @@ typedef struct ...@@ -54,8 +54,6 @@ typedef struct
# error You must define GET_IP for this CPU # error You must define GET_IP for this CPU
#endif #endif
extern void SIGNAL_Unblock(void);
void WINAPI EXC_RtlRaiseException( PEXCEPTION_RECORD, PCONTEXT ); void WINAPI EXC_RtlRaiseException( PEXCEPTION_RECORD, PCONTEXT );
void WINAPI EXC_RtlUnwind( PEXCEPTION_FRAME, LPVOID, void WINAPI EXC_RtlUnwind( PEXCEPTION_FRAME, LPVOID,
PEXCEPTION_RECORD, DWORD, PCONTEXT ); PEXCEPTION_RECORD, DWORD, PCONTEXT );
......
...@@ -422,8 +422,6 @@ typedef int (*wine_signal_handler)(unsigned int sig); ...@@ -422,8 +422,6 @@ typedef int (*wine_signal_handler)(unsigned int sig);
static wine_signal_handler handlers[256]; static wine_signal_handler handlers[256];
static sigset_t all_sigs;
extern void WINAPI EXC_RtlRaiseException( PEXCEPTION_RECORD, PCONTEXT ); extern void WINAPI EXC_RtlRaiseException( PEXCEPTION_RECORD, PCONTEXT );
/*********************************************************************** /***********************************************************************
...@@ -752,17 +750,6 @@ static inline DWORD get_fpu_code( const CONTEXT *context ) ...@@ -752,17 +750,6 @@ static inline DWORD get_fpu_code( const CONTEXT *context )
} }
/***********************************************************************
* SIGNAL_Unblock
*
* Unblock signals. Called from EXC_RtlRaiseException.
*/
void SIGNAL_Unblock( void )
{
sigprocmask( SIG_UNBLOCK, &all_sigs, NULL );
}
/********************************************************************** /**********************************************************************
* do_segv * do_segv
* *
...@@ -1106,6 +1093,18 @@ static HANDLER_DEF(abrt_handler) ...@@ -1106,6 +1093,18 @@ static HANDLER_DEF(abrt_handler)
/********************************************************************** /**********************************************************************
* term_handler
*
* Handler for SIGTERM.
*/
static HANDLER_DEF(term_handler)
{
init_handler( HANDLER_CONTEXT );
SYSDEPS_AbortThread(0);
}
/**********************************************************************
* usr1_handler * usr1_handler
* *
* Handler for SIGUSR1, used to signal a thread that it got suspended. * Handler for SIGUSR1, used to signal a thread that it got suspended.
...@@ -1197,13 +1196,12 @@ BOOL SIGNAL_Init(void) ...@@ -1197,13 +1196,12 @@ BOOL SIGNAL_Init(void)
} }
#endif /* HAVE_SIGALTSTACK */ #endif /* HAVE_SIGALTSTACK */
sigfillset( &all_sigs );
if (set_handler( SIGINT, have_sigaltstack, (void (*)())int_handler ) == -1) goto error; if (set_handler( SIGINT, have_sigaltstack, (void (*)())int_handler ) == -1) goto error;
if (set_handler( SIGFPE, have_sigaltstack, (void (*)())fpe_handler ) == -1) goto error; if (set_handler( SIGFPE, have_sigaltstack, (void (*)())fpe_handler ) == -1) goto error;
if (set_handler( SIGSEGV, have_sigaltstack, (void (*)())segv_handler ) == -1) goto error; if (set_handler( SIGSEGV, have_sigaltstack, (void (*)())segv_handler ) == -1) goto error;
if (set_handler( SIGILL, have_sigaltstack, (void (*)())segv_handler ) == -1) goto error; if (set_handler( SIGILL, have_sigaltstack, (void (*)())segv_handler ) == -1) goto error;
if (set_handler( SIGABRT, have_sigaltstack, (void (*)())abrt_handler ) == -1) goto error; if (set_handler( SIGABRT, have_sigaltstack, (void (*)())abrt_handler ) == -1) goto error;
if (set_handler( SIGTERM, have_sigaltstack, (void (*)())term_handler ) == -1) goto error;
if (set_handler( SIGUSR1, have_sigaltstack, (void (*)())usr1_handler ) == -1) goto error; if (set_handler( SIGUSR1, have_sigaltstack, (void (*)())usr1_handler ) == -1) goto error;
#ifdef SIGBUS #ifdef SIGBUS
if (set_handler( SIGBUS, have_sigaltstack, (void (*)())segv_handler ) == -1) goto error; if (set_handler( SIGBUS, have_sigaltstack, (void (*)())segv_handler ) == -1) goto error;
...@@ -1226,13 +1224,14 @@ BOOL SIGNAL_Init(void) ...@@ -1226,13 +1224,14 @@ BOOL SIGNAL_Init(void)
/********************************************************************** /**********************************************************************
* SIGNAL_Reset * SIGNAL_Block
*
* Block the async signals.
*/ */
void SIGNAL_Reset(void) void SIGNAL_Block(void)
{ {
sigset_t block_set; sigset_t block_set;
/* block the async signals */
sigemptyset( &block_set ); sigemptyset( &block_set );
sigaddset( &block_set, SIGALRM ); sigaddset( &block_set, SIGALRM );
sigaddset( &block_set, SIGIO ); sigaddset( &block_set, SIGIO );
...@@ -1240,12 +1239,36 @@ void SIGNAL_Reset(void) ...@@ -1240,12 +1239,36 @@ void SIGNAL_Reset(void)
sigaddset( &block_set, SIGUSR1 ); sigaddset( &block_set, SIGUSR1 );
sigaddset( &block_set, SIGUSR2 ); sigaddset( &block_set, SIGUSR2 );
sigprocmask( SIG_BLOCK, &block_set, NULL ); sigprocmask( SIG_BLOCK, &block_set, NULL );
}
/***********************************************************************
* SIGNAL_Unblock
*
* Unblock signals. Called from EXC_RtlRaiseException.
*/
void SIGNAL_Unblock(void)
{
sigset_t all_sigs;
/* restore default handlers */ sigfillset( &all_sigs );
sigprocmask( SIG_UNBLOCK, &all_sigs, NULL );
}
/**********************************************************************
* SIGNAL_Reset
*
* Restore the default handlers.
*/
void SIGNAL_Reset(void)
{
signal( SIGINT, SIG_DFL ); signal( SIGINT, SIG_DFL );
signal( SIGFPE, SIG_DFL ); signal( SIGFPE, SIG_DFL );
signal( SIGSEGV, SIG_DFL ); signal( SIGSEGV, SIG_DFL );
signal( SIGILL, SIG_DFL ); signal( SIGILL, SIG_DFL );
signal( SIGABRT, SIG_DFL );
signal( SIGTERM, SIG_DFL );
#ifdef SIGBUS #ifdef SIGBUS
signal( SIGBUS, SIG_DFL ); signal( SIGBUS, SIG_DFL );
#endif #endif
......
...@@ -76,8 +76,6 @@ typedef int (*wine_signal_handler)(unsigned int sig); ...@@ -76,8 +76,6 @@ typedef int (*wine_signal_handler)(unsigned int sig);
static wine_signal_handler handlers[256]; static wine_signal_handler handlers[256];
static sigset_t all_sigs;
extern void WINAPI EXC_RtlRaiseException( PEXCEPTION_RECORD, PCONTEXT ); extern void WINAPI EXC_RtlRaiseException( PEXCEPTION_RECORD, PCONTEXT );
/*********************************************************************** /***********************************************************************
...@@ -190,16 +188,6 @@ static inline DWORD get_fpu_code( const CONTEXT *context ) ...@@ -190,16 +188,6 @@ static inline DWORD get_fpu_code( const CONTEXT *context )
} }
/***********************************************************************
* SIGNAL_Unblock
*
* Unblock signals. Called from EXC_RtlRaiseException.
*/
void SIGNAL_Unblock( void )
{
sigprocmask( SIG_UNBLOCK, &all_sigs, NULL );
}
/********************************************************************** /**********************************************************************
* segv_handler * segv_handler
* *
...@@ -404,6 +392,17 @@ static HANDLER_DEF(abrt_handler) ...@@ -404,6 +392,17 @@ static HANDLER_DEF(abrt_handler)
/********************************************************************** /**********************************************************************
* term_handler
*
* Handler for SIGTERM.
*/
static HANDLER_DEF(term_handler)
{
SYSDEPS_AbortThread(0);
}
/**********************************************************************
* usr1_handler * usr1_handler
* *
* Handler for SIGUSR1, used to signal a thread that it got suspended. * Handler for SIGUSR1, used to signal a thread that it got suspended.
...@@ -474,6 +473,7 @@ BOOL SIGNAL_Init(void) ...@@ -474,6 +473,7 @@ BOOL SIGNAL_Init(void)
if (set_handler( SIGSEGV, have_sigaltstack, (void (*)())segv_handler ) == -1) goto error; if (set_handler( SIGSEGV, have_sigaltstack, (void (*)())segv_handler ) == -1) goto error;
if (set_handler( SIGILL, have_sigaltstack, (void (*)())segv_handler ) == -1) goto error; if (set_handler( SIGILL, have_sigaltstack, (void (*)())segv_handler ) == -1) goto error;
if (set_handler( SIGABRT, have_sigaltstack, (void (*)())abrt_handler ) == -1) goto error; if (set_handler( SIGABRT, have_sigaltstack, (void (*)())abrt_handler ) == -1) goto error;
if (set_handler( SIGTERM, have_sigaltstack, (void (*)())term_handler ) == -1) goto error;
if (set_handler( SIGUSR1, have_sigaltstack, (void (*)())usr1_handler ) == -1) goto error; if (set_handler( SIGUSR1, have_sigaltstack, (void (*)())usr1_handler ) == -1) goto error;
#ifdef SIGBUS #ifdef SIGBUS
if (set_handler( SIGBUS, have_sigaltstack, (void (*)())segv_handler ) == -1) goto error; if (set_handler( SIGBUS, have_sigaltstack, (void (*)())segv_handler ) == -1) goto error;
...@@ -491,13 +491,14 @@ BOOL SIGNAL_Init(void) ...@@ -491,13 +491,14 @@ BOOL SIGNAL_Init(void)
/********************************************************************** /**********************************************************************
* SIGNAL_Reset * SIGNAL_Block
*
* Block the async signals.
*/ */
void SIGNAL_Reset(void) void SIGNAL_Block(void)
{ {
sigset_t block_set; sigset_t block_set;
/* block the async signals */
sigemptyset( &block_set ); sigemptyset( &block_set );
sigaddset( &block_set, SIGALRM ); sigaddset( &block_set, SIGALRM );
sigaddset( &block_set, SIGIO ); sigaddset( &block_set, SIGIO );
...@@ -505,12 +506,36 @@ void SIGNAL_Reset(void) ...@@ -505,12 +506,36 @@ void SIGNAL_Reset(void)
sigaddset( &block_set, SIGUSR1 ); sigaddset( &block_set, SIGUSR1 );
sigaddset( &block_set, SIGUSR2 ); sigaddset( &block_set, SIGUSR2 );
sigprocmask( SIG_BLOCK, &block_set, NULL ); sigprocmask( SIG_BLOCK, &block_set, NULL );
}
/* restore default handlers */
/***********************************************************************
* SIGNAL_Unblock
*
* Unblock signals. Called from EXC_RtlRaiseException.
*/
void SIGNAL_Unblock(void)
{
sigset_t all_sigs;
sigfillset( &all_sigs );
sigprocmask( SIG_UNBLOCK, &all_sigs, NULL );
}
/**********************************************************************
* SIGNAL_Reset
*
* Restore the default handlers.
*/
void SIGNAL_Reset(void)
{
signal( SIGINT, SIG_DFL ); signal( SIGINT, SIG_DFL );
signal( SIGFPE, SIG_DFL ); signal( SIGFPE, SIG_DFL );
signal( SIGSEGV, SIG_DFL ); signal( SIGSEGV, SIG_DFL );
signal( SIGILL, SIG_DFL ); signal( SIGILL, SIG_DFL );
signal( SIGABRT, SIG_DFL );
signal( SIGTERM, SIG_DFL );
#ifdef SIGBUS #ifdef SIGBUS
signal( SIGBUS, SIG_DFL ); signal( SIGBUS, SIG_DFL );
#endif #endif
...@@ -519,6 +544,7 @@ void SIGNAL_Reset(void) ...@@ -519,6 +544,7 @@ void SIGNAL_Reset(void)
#endif #endif
} }
/********************************************************************** /**********************************************************************
* __wine_enter_vm86 (NTDLL.@) * __wine_enter_vm86 (NTDLL.@)
*/ */
......
...@@ -49,8 +49,6 @@ typedef int (*wine_signal_handler)(unsigned int sig); ...@@ -49,8 +49,6 @@ typedef int (*wine_signal_handler)(unsigned int sig);
static wine_signal_handler handlers[256]; static wine_signal_handler handlers[256];
static sigset_t all_sigs;
extern void WINAPI EXC_RtlRaiseException( PEXCEPTION_RECORD, PCONTEXT ); extern void WINAPI EXC_RtlRaiseException( PEXCEPTION_RECORD, PCONTEXT );
/*********************************************************************** /***********************************************************************
...@@ -369,6 +367,17 @@ static HANDLER_DEF(abrt_handler) ...@@ -369,6 +367,17 @@ static HANDLER_DEF(abrt_handler)
/********************************************************************** /**********************************************************************
* term_handler
*
* Handler for SIGTERM.
*/
static HANDLER_DEF(term_handler)
{
SYSDEPS_AbortThread(0);
}
/**********************************************************************
* usr1_handler * usr1_handler
* *
* Handler for SIGUSR1, used to signal a thread that it got suspended. * Handler for SIGUSR1, used to signal a thread that it got suspended.
...@@ -410,17 +419,6 @@ int __wine_set_signal_handler(unsigned int sig, wine_signal_handler wsh) ...@@ -410,17 +419,6 @@ int __wine_set_signal_handler(unsigned int sig, wine_signal_handler wsh)
} }
/***********************************************************************
* SIGNAL_Unblock
*
* Unblock signals. Called from EXC_RtlRaiseException.
*/
void SIGNAL_Unblock( void )
{
sigprocmask( SIG_UNBLOCK, &all_sigs, NULL );
}
/********************************************************************** /**********************************************************************
* SIGNAL_Init * SIGNAL_Init
*/ */
...@@ -435,6 +433,7 @@ BOOL SIGNAL_Init(void) ...@@ -435,6 +433,7 @@ BOOL SIGNAL_Init(void)
if (set_handler( SIGBUS, (void (*)())bus_handler ) == -1) goto error; if (set_handler( SIGBUS, (void (*)())bus_handler ) == -1) goto error;
if (set_handler( SIGTRAP, (void (*)())trap_handler ) == -1) goto error; if (set_handler( SIGTRAP, (void (*)())trap_handler ) == -1) goto error;
if (set_handler( SIGABRT, (void (*)())abrt_handler ) == -1) goto error; if (set_handler( SIGABRT, (void (*)())abrt_handler ) == -1) goto error;
if (set_handler( SIGTERM, (void (*)())term_handler ) == -1) goto error;
if (set_handler( SIGUSR1, (void (*)())usr1_handler ) == -1) goto error; if (set_handler( SIGUSR1, (void (*)())usr1_handler ) == -1) goto error;
return TRUE; return TRUE;
...@@ -445,13 +444,14 @@ BOOL SIGNAL_Init(void) ...@@ -445,13 +444,14 @@ BOOL SIGNAL_Init(void)
/********************************************************************** /**********************************************************************
* SIGNAL_Reset * SIGNAL_Block
*
* Block the async signals.
*/ */
void SIGNAL_Reset(void) void SIGNAL_Block(void)
{ {
sigset_t block_set; sigset_t block_set;
/* block the async signals */
sigemptyset( &block_set ); sigemptyset( &block_set );
sigaddset( &block_set, SIGALRM ); sigaddset( &block_set, SIGALRM );
sigaddset( &block_set, SIGIO ); sigaddset( &block_set, SIGIO );
...@@ -459,14 +459,38 @@ void SIGNAL_Reset(void) ...@@ -459,14 +459,38 @@ void SIGNAL_Reset(void)
sigaddset( &block_set, SIGUSR1 ); sigaddset( &block_set, SIGUSR1 );
sigaddset( &block_set, SIGUSR2 ); sigaddset( &block_set, SIGUSR2 );
sigprocmask( SIG_BLOCK, &block_set, NULL ); sigprocmask( SIG_BLOCK, &block_set, NULL );
}
/***********************************************************************
* SIGNAL_Unblock
*
* Unblock signals. Called from EXC_RtlRaiseException.
*/
void SIGNAL_Unblock(void)
{
sigset_t all_sigs;
sigfillset( &all_sigs );
sigprocmask( SIG_UNBLOCK, &all_sigs, NULL );
}
/* restore default handlers */
/**********************************************************************
* SIGNAL_Reset
*
* Restore the default handlers.
*/
void SIGNAL_Reset(void)
{
signal( SIGINT, SIG_DFL ); signal( SIGINT, SIG_DFL );
signal( SIGFPE, SIG_DFL ); signal( SIGFPE, SIG_DFL );
signal( SIGSEGV, SIG_DFL ); signal( SIGSEGV, SIG_DFL );
signal( SIGILL, SIG_DFL ); signal( SIGILL, SIG_DFL );
signal( SIGBUS, SIG_DFL ); signal( SIGBUS, SIG_DFL );
signal( SIGTRAP, SIG_DFL ); signal( SIGTRAP, SIG_DFL );
signal( SIGABRT, SIG_DFL );
signal( SIGTERM, SIG_DFL );
} }
......
...@@ -153,6 +153,8 @@ extern void DECLSPEC_NORETURN SYSDEPS_SwitchToThreadStack( void (*func)(void) ); ...@@ -153,6 +153,8 @@ extern void DECLSPEC_NORETURN SYSDEPS_SwitchToThreadStack( void (*func)(void) );
/* signal handling */ /* signal handling */
extern BOOL SIGNAL_Init(void); extern BOOL SIGNAL_Init(void);
extern void SIGNAL_Block(void);
extern void SIGNAL_Unblock(void);
extern void SIGNAL_Reset(void); extern void SIGNAL_Reset(void);
#endif /* __WINE_THREAD_H */ #endif /* __WINE_THREAD_H */
...@@ -284,6 +284,7 @@ void SYSDEPS_ExitThread( int status ) ...@@ -284,6 +284,7 @@ void SYSDEPS_ExitThread( int status )
info.stack_size = meminfo.RegionSize + ((char *)teb->stack_top - (char *)meminfo.AllocationBase); info.stack_size = meminfo.RegionSize + ((char *)teb->stack_top - (char *)meminfo.AllocationBase);
info.status = status; info.status = status;
SIGNAL_Block();
SIGNAL_Reset(); SIGNAL_Reset();
VirtualFree( teb->stack_base, 0, MEM_RELEASE | MEM_SYSTEM ); VirtualFree( teb->stack_base, 0, MEM_RELEASE | MEM_SYSTEM );
...@@ -304,6 +305,7 @@ void SYSDEPS_ExitThread( int status ) ...@@ -304,6 +305,7 @@ void SYSDEPS_ExitThread( int status )
*/ */
void SYSDEPS_AbortThread( int status ) void SYSDEPS_AbortThread( int status )
{ {
SIGNAL_Block();
SIGNAL_Reset(); SIGNAL_Reset();
close( NtCurrentTeb()->wait_fd[0] ); close( NtCurrentTeb()->wait_fd[0] );
close( NtCurrentTeb()->wait_fd[1] ); close( NtCurrentTeb()->wait_fd[1] );
......
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