mirror of
https://gitlab.winehq.org/wine/wine.git
synced 2024-11-19 17:06:04 -07:00
tools: Add a common helper to setup signal handlers.
This commit is contained in:
parent
9f0ae8c992
commit
ae8797c8e3
9 changed files with 18 additions and 49 deletions
|
@ -20,7 +20,6 @@
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include <signal.h>
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
@ -478,11 +477,7 @@ int main(int argc, char **argv)
|
||||||
} else {
|
} else {
|
||||||
output_file = option_outfile_name;
|
output_file = option_outfile_name;
|
||||||
atexit(cleanup_files);
|
atexit(cleanup_files);
|
||||||
signal(SIGTERM, exit_on_signal);
|
init_signals( exit_on_signal );
|
||||||
signal(SIGINT, exit_on_signal);
|
|
||||||
#ifdef SIGHUP
|
|
||||||
signal(SIGHUP, exit_on_signal);
|
|
||||||
#endif
|
|
||||||
if (!(outfile = fopen(output_file, "wb"))) {
|
if (!(outfile = fopen(output_file, "wb"))) {
|
||||||
perror(option_outfile_name);
|
perror(option_outfile_name);
|
||||||
goto error;
|
goto error;
|
||||||
|
|
|
@ -27,7 +27,6 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <signal.h>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
@ -4395,11 +4394,7 @@ int main( int argc, char *argv[] )
|
||||||
if (argc > 1) fatal_error( "Directory arguments not supported in this mode\n" );
|
if (argc > 1) fatal_error( "Directory arguments not supported in this mode\n" );
|
||||||
|
|
||||||
atexit( cleanup_files );
|
atexit( cleanup_files );
|
||||||
signal( SIGTERM, exit_on_signal );
|
init_signals( exit_on_signal );
|
||||||
signal( SIGINT, exit_on_signal );
|
|
||||||
#ifdef SIGHUP
|
|
||||||
signal( SIGHUP, exit_on_signal );
|
|
||||||
#endif
|
|
||||||
|
|
||||||
for (i = 0; i < HASH_SIZE; i++) list_init( &files[i] );
|
for (i = 0; i < HASH_SIZE; i++) list_init( &files[i] );
|
||||||
for (i = 0; i < HASH_SIZE; i++) list_init( &global_includes[i] );
|
for (i = 0; i < HASH_SIZE; i++) list_init( &global_includes[i] );
|
||||||
|
|
|
@ -23,7 +23,6 @@
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <signal.h>
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
@ -912,11 +911,7 @@ int main(int argc, char **argv)
|
||||||
font_off = (fontdir_off + fontdir_len + 15) & ~0x0f;
|
font_off = (fontdir_off + fontdir_len + 15) & ~0x0f;
|
||||||
|
|
||||||
atexit( cleanup );
|
atexit( cleanup );
|
||||||
signal( SIGTERM, exit_on_signal );
|
init_signals( exit_on_signal );
|
||||||
signal( SIGINT, exit_on_signal );
|
|
||||||
#ifdef SIGHUP
|
|
||||||
signal( SIGHUP, exit_on_signal );
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (!output_name) /* build a default output name */
|
if (!output_name) /* build a default output name */
|
||||||
output_name = strmake( "%s%s", get_basename_noext( input_file ),
|
output_name = strmake( "%s%s", get_basename_noext( input_file ),
|
||||||
|
|
|
@ -401,6 +401,16 @@ static inline void remove_temp_files(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static inline void init_signals( void (*cleanup)(int) )
|
||||||
|
{
|
||||||
|
signal( SIGTERM, cleanup );
|
||||||
|
signal( SIGINT, cleanup );
|
||||||
|
#ifdef SIGHUP
|
||||||
|
signal( SIGHUP, cleanup );
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static inline void *read_file( const char *name, size_t *size )
|
static inline void *read_file( const char *name, size_t *size )
|
||||||
{
|
{
|
||||||
struct stat st;
|
struct stat st;
|
||||||
|
|
|
@ -28,7 +28,6 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <signal.h>
|
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
@ -704,11 +703,7 @@ int main(int argc,char *argv[])
|
||||||
struct strarray files;
|
struct strarray files;
|
||||||
char *input;
|
char *input;
|
||||||
|
|
||||||
signal( SIGTERM, exit_on_signal );
|
init_signals( exit_on_signal );
|
||||||
signal( SIGINT, exit_on_signal );
|
|
||||||
#ifdef SIGHUP
|
|
||||||
signal( SIGHUP, exit_on_signal );
|
|
||||||
#endif
|
|
||||||
init_argv0_dir( argv[0] );
|
init_argv0_dir( argv[0] );
|
||||||
target = init_argv0_target( argv[0] );
|
target = init_argv0_target( argv[0] );
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,6 @@
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <signal.h>
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
@ -619,12 +618,7 @@ int main(int argc, char **argv)
|
||||||
struct strarray files;
|
struct strarray files;
|
||||||
DLLSPEC *spec = main_spec = alloc_dll_spec();
|
DLLSPEC *spec = main_spec = alloc_dll_spec();
|
||||||
|
|
||||||
#ifdef SIGHUP
|
init_signals( exit_on_signal );
|
||||||
signal( SIGHUP, exit_on_signal );
|
|
||||||
#endif
|
|
||||||
signal( SIGTERM, exit_on_signal );
|
|
||||||
signal( SIGINT, exit_on_signal );
|
|
||||||
|
|
||||||
target = init_argv0_target( argv[0] );
|
target = init_argv0_target( argv[0] );
|
||||||
if (target.platform == PLATFORM_CYGWIN) target.platform = PLATFORM_MINGW;
|
if (target.platform == PLATFORM_CYGWIN) target.platform = PLATFORM_MINGW;
|
||||||
if (is_pe()) unwind_tables = 1;
|
if (is_pe()) unwind_tables = 1;
|
||||||
|
|
|
@ -91,7 +91,6 @@
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <signal.h>
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
@ -1488,11 +1487,7 @@ int main(int argc, char **argv)
|
||||||
char* lang = 0;
|
char* lang = 0;
|
||||||
char* str;
|
char* str;
|
||||||
|
|
||||||
#ifdef SIGHUP
|
init_signals( exit_on_signal );
|
||||||
signal( SIGHUP, exit_on_signal );
|
|
||||||
#endif
|
|
||||||
signal( SIGTERM, exit_on_signal );
|
|
||||||
signal( SIGINT, exit_on_signal );
|
|
||||||
init_argv0_dir( argv[0] );
|
init_argv0_dir( argv[0] );
|
||||||
|
|
||||||
/* setup tmp file removal at exit */
|
/* setup tmp file removal at exit */
|
||||||
|
|
|
@ -23,7 +23,6 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <signal.h>
|
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
@ -221,11 +220,7 @@ int main(int argc,char *argv[])
|
||||||
struct strarray files;
|
struct strarray files;
|
||||||
|
|
||||||
atexit( cleanup_files );
|
atexit( cleanup_files );
|
||||||
signal( SIGTERM, exit_on_signal );
|
init_signals( exit_on_signal );
|
||||||
signal( SIGINT, exit_on_signal );
|
|
||||||
#ifdef SIGHUP
|
|
||||||
signal( SIGHUP, exit_on_signal );
|
|
||||||
#endif
|
|
||||||
init_argv0_dir( argv[0] );
|
init_argv0_dir( argv[0] );
|
||||||
|
|
||||||
/* First rebuild the commandline to put in destination */
|
/* First rebuild the commandline to put in destination */
|
||||||
|
|
|
@ -26,7 +26,6 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <signal.h>
|
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
@ -396,11 +395,7 @@ int main(int argc,char *argv[])
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
signal( SIGTERM, exit_on_signal );
|
init_signals( exit_on_signal );
|
||||||
signal( SIGINT, exit_on_signal );
|
|
||||||
#ifdef SIGHUP
|
|
||||||
signal( SIGHUP, exit_on_signal );
|
|
||||||
#endif
|
|
||||||
init_argv0_dir( argv[0] );
|
init_argv0_dir( argv[0] );
|
||||||
|
|
||||||
/* Set the default defined stuff */
|
/* Set the default defined stuff */
|
||||||
|
|
Loading…
Reference in a new issue