Split signal blocking code out of SIGNAL_Reset into SIGNAL_Block.
Added SIGTERM handler.
This commit is contained in:
parent
bace7a11ca
commit
6a26e3f7ac
|
@ -54,8 +54,6 @@ typedef struct
|
|||
# error You must define GET_IP for this CPU
|
||||
#endif
|
||||
|
||||
extern void SIGNAL_Unblock(void);
|
||||
|
||||
void WINAPI EXC_RtlRaiseException( PEXCEPTION_RECORD, PCONTEXT );
|
||||
void WINAPI EXC_RtlUnwind( PEXCEPTION_FRAME, LPVOID,
|
||||
PEXCEPTION_RECORD, DWORD, PCONTEXT );
|
||||
|
|
|
@ -422,8 +422,6 @@ typedef int (*wine_signal_handler)(unsigned int sig);
|
|||
|
||||
static wine_signal_handler handlers[256];
|
||||
|
||||
static sigset_t all_sigs;
|
||||
|
||||
extern void WINAPI EXC_RtlRaiseException( PEXCEPTION_RECORD, PCONTEXT );
|
||||
|
||||
/***********************************************************************
|
||||
|
@ -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
|
||||
*
|
||||
|
@ -1105,6 +1092,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
|
||||
*
|
||||
|
@ -1197,13 +1196,12 @@ BOOL SIGNAL_Init(void)
|
|||
}
|
||||
#endif /* HAVE_SIGALTSTACK */
|
||||
|
||||
sigfillset( &all_sigs );
|
||||
|
||||
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( SIGSEGV, 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( SIGTERM, have_sigaltstack, (void (*)())term_handler ) == -1) goto error;
|
||||
if (set_handler( SIGUSR1, have_sigaltstack, (void (*)())usr1_handler ) == -1) goto error;
|
||||
#ifdef SIGBUS
|
||||
if (set_handler( SIGBUS, have_sigaltstack, (void (*)())segv_handler ) == -1) goto error;
|
||||
|
@ -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;
|
||||
|
||||
/* block the async signals */
|
||||
sigemptyset( &block_set );
|
||||
sigaddset( &block_set, SIGALRM );
|
||||
sigaddset( &block_set, SIGIO );
|
||||
|
@ -1240,12 +1239,36 @@ void SIGNAL_Reset(void)
|
|||
sigaddset( &block_set, SIGUSR1 );
|
||||
sigaddset( &block_set, SIGUSR2 );
|
||||
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( SIGFPE, SIG_DFL );
|
||||
signal( SIGSEGV, SIG_DFL );
|
||||
signal( SIGILL, SIG_DFL );
|
||||
signal( SIGABRT, SIG_DFL );
|
||||
signal( SIGTERM, SIG_DFL );
|
||||
#ifdef SIGBUS
|
||||
signal( SIGBUS, SIG_DFL );
|
||||
#endif
|
||||
|
|
|
@ -76,8 +76,6 @@ typedef int (*wine_signal_handler)(unsigned int sig);
|
|||
|
||||
static wine_signal_handler handlers[256];
|
||||
|
||||
static sigset_t all_sigs;
|
||||
|
||||
extern void WINAPI EXC_RtlRaiseException( PEXCEPTION_RECORD, PCONTEXT );
|
||||
|
||||
/***********************************************************************
|
||||
|
@ -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
|
||||
*
|
||||
|
@ -403,6 +391,17 @@ static HANDLER_DEF(abrt_handler)
|
|||
}
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* term_handler
|
||||
*
|
||||
* Handler for SIGTERM.
|
||||
*/
|
||||
static HANDLER_DEF(term_handler)
|
||||
{
|
||||
SYSDEPS_AbortThread(0);
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* usr1_handler
|
||||
*
|
||||
|
@ -474,6 +473,7 @@ BOOL SIGNAL_Init(void)
|
|||
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( 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;
|
||||
#ifdef SIGBUS
|
||||
if (set_handler( SIGBUS, have_sigaltstack, (void (*)())segv_handler ) == -1) goto error;
|
||||
|
@ -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;
|
||||
|
||||
/* block the async signals */
|
||||
sigemptyset( &block_set );
|
||||
sigaddset( &block_set, SIGALRM );
|
||||
sigaddset( &block_set, SIGIO );
|
||||
|
@ -505,12 +506,36 @@ void SIGNAL_Reset(void)
|
|||
sigaddset( &block_set, SIGUSR1 );
|
||||
sigaddset( &block_set, SIGUSR2 );
|
||||
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( SIGFPE, SIG_DFL );
|
||||
signal( SIGSEGV, SIG_DFL );
|
||||
signal( SIGILL, SIG_DFL );
|
||||
signal( SIGABRT, SIG_DFL );
|
||||
signal( SIGTERM, SIG_DFL );
|
||||
#ifdef SIGBUS
|
||||
signal( SIGBUS, SIG_DFL );
|
||||
#endif
|
||||
|
@ -519,6 +544,7 @@ void SIGNAL_Reset(void)
|
|||
#endif
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* __wine_enter_vm86 (NTDLL.@)
|
||||
*/
|
||||
|
|
|
@ -49,8 +49,6 @@ typedef int (*wine_signal_handler)(unsigned int sig);
|
|||
|
||||
static wine_signal_handler handlers[256];
|
||||
|
||||
static sigset_t all_sigs;
|
||||
|
||||
extern void WINAPI EXC_RtlRaiseException( PEXCEPTION_RECORD, PCONTEXT );
|
||||
|
||||
/***********************************************************************
|
||||
|
@ -368,6 +366,17 @@ static HANDLER_DEF(abrt_handler)
|
|||
}
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* term_handler
|
||||
*
|
||||
* Handler for SIGTERM.
|
||||
*/
|
||||
static HANDLER_DEF(term_handler)
|
||||
{
|
||||
SYSDEPS_AbortThread(0);
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* usr1_handler
|
||||
*
|
||||
|
@ -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
|
||||
*/
|
||||
|
@ -435,6 +433,7 @@ BOOL SIGNAL_Init(void)
|
|||
if (set_handler( SIGBUS, (void (*)())bus_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( SIGTERM, (void (*)())term_handler ) == -1) goto error;
|
||||
if (set_handler( SIGUSR1, (void (*)())usr1_handler ) == -1) goto error;
|
||||
return TRUE;
|
||||
|
||||
|
@ -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;
|
||||
|
||||
/* block the async signals */
|
||||
sigemptyset( &block_set );
|
||||
sigaddset( &block_set, SIGALRM );
|
||||
sigaddset( &block_set, SIGIO );
|
||||
|
@ -459,14 +459,38 @@ void SIGNAL_Reset(void)
|
|||
sigaddset( &block_set, SIGUSR1 );
|
||||
sigaddset( &block_set, SIGUSR2 );
|
||||
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( SIGFPE, SIG_DFL );
|
||||
signal( SIGSEGV, SIG_DFL );
|
||||
signal( SIGILL, SIG_DFL );
|
||||
signal( SIGBUS, 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) );
|
|||
|
||||
/* signal handling */
|
||||
extern BOOL SIGNAL_Init(void);
|
||||
extern void SIGNAL_Block(void);
|
||||
extern void SIGNAL_Unblock(void);
|
||||
extern void SIGNAL_Reset(void);
|
||||
|
||||
#endif /* __WINE_THREAD_H */
|
||||
|
|
|
@ -284,6 +284,7 @@ void SYSDEPS_ExitThread( int status )
|
|||
info.stack_size = meminfo.RegionSize + ((char *)teb->stack_top - (char *)meminfo.AllocationBase);
|
||||
info.status = status;
|
||||
|
||||
SIGNAL_Block();
|
||||
SIGNAL_Reset();
|
||||
|
||||
VirtualFree( teb->stack_base, 0, MEM_RELEASE | MEM_SYSTEM );
|
||||
|
@ -304,6 +305,7 @@ void SYSDEPS_ExitThread( int status )
|
|||
*/
|
||||
void SYSDEPS_AbortThread( int status )
|
||||
{
|
||||
SIGNAL_Block();
|
||||
SIGNAL_Reset();
|
||||
close( NtCurrentTeb()->wait_fd[0] );
|
||||
close( NtCurrentTeb()->wait_fd[1] );
|
||||
|
|
Loading…
Reference in New Issue