1
0
mirror of https://github.com/wine-mirror/wine synced 2024-06-29 06:14:34 +00:00

tools: Add a common helper to setup signal handlers.

This commit is contained in:
Alexandre Julliard 2023-01-25 11:32:32 +01:00
parent 9f0ae8c992
commit ae8797c8e3
9 changed files with 18 additions and 49 deletions

View File

@ -20,7 +20,6 @@
#include "config.h"
#include <signal.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
@ -478,11 +477,7 @@ int main(int argc, char **argv)
} else {
output_file = option_outfile_name;
atexit(cleanup_files);
signal(SIGTERM, exit_on_signal);
signal(SIGINT, exit_on_signal);
#ifdef SIGHUP
signal(SIGHUP, exit_on_signal);
#endif
init_signals( exit_on_signal );
if (!(outfile = fopen(output_file, "wb"))) {
perror(option_outfile_name);
goto error;

View File

@ -27,7 +27,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <signal.h>
#include <string.h>
#include <sys/types.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" );
atexit( cleanup_files );
signal( SIGTERM, exit_on_signal );
signal( SIGINT, exit_on_signal );
#ifdef SIGHUP
signal( SIGHUP, exit_on_signal );
#endif
init_signals( exit_on_signal );
for (i = 0; i < HASH_SIZE; i++) list_init( &files[i] );
for (i = 0; i < HASH_SIZE; i++) list_init( &global_includes[i] );

View File

@ -23,7 +23,6 @@
#include <assert.h>
#include <ctype.h>
#include <errno.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
@ -912,11 +911,7 @@ int main(int argc, char **argv)
font_off = (fontdir_off + fontdir_len + 15) & ~0x0f;
atexit( cleanup );
signal( SIGTERM, exit_on_signal );
signal( SIGINT, exit_on_signal );
#ifdef SIGHUP
signal( SIGHUP, exit_on_signal );
#endif
init_signals( exit_on_signal );
if (!output_name) /* build a default output name */
output_name = strmake( "%s%s", get_basename_noext( input_file ),

View 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 )
{
struct stat st;

View File

@ -28,7 +28,6 @@
#include <string.h>
#include <assert.h>
#include <ctype.h>
#include <signal.h>
#include <limits.h>
#include <sys/types.h>
@ -704,11 +703,7 @@ int main(int argc,char *argv[])
struct strarray files;
char *input;
signal( SIGTERM, exit_on_signal );
signal( SIGINT, exit_on_signal );
#ifdef SIGHUP
signal( SIGHUP, exit_on_signal );
#endif
init_signals( exit_on_signal );
init_argv0_dir( argv[0] );
target = init_argv0_target( argv[0] );

View File

@ -26,7 +26,6 @@
#include <assert.h>
#include <stdio.h>
#include <signal.h>
#include <errno.h>
#include <string.h>
#include <stdarg.h>
@ -619,12 +618,7 @@ int main(int argc, char **argv)
struct strarray files;
DLLSPEC *spec = main_spec = alloc_dll_spec();
#ifdef SIGHUP
signal( SIGHUP, exit_on_signal );
#endif
signal( SIGTERM, exit_on_signal );
signal( SIGINT, exit_on_signal );
init_signals( exit_on_signal );
target = init_argv0_target( argv[0] );
if (target.platform == PLATFORM_CYGWIN) target.platform = PLATFORM_MINGW;
if (is_pe()) unwind_tables = 1;

View File

@ -91,7 +91,6 @@
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <stdarg.h>
#include <string.h>
#include <errno.h>
@ -1488,11 +1487,7 @@ int main(int argc, char **argv)
char* lang = 0;
char* str;
#ifdef SIGHUP
signal( SIGHUP, exit_on_signal );
#endif
signal( SIGTERM, exit_on_signal );
signal( SIGINT, exit_on_signal );
init_signals( exit_on_signal );
init_argv0_dir( argv[0] );
/* setup tmp file removal at exit */

View File

@ -23,7 +23,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <signal.h>
#include <limits.h>
#include <sys/types.h>
@ -221,11 +220,7 @@ int main(int argc,char *argv[])
struct strarray files;
atexit( cleanup_files );
signal( SIGTERM, exit_on_signal );
signal( SIGINT, exit_on_signal );
#ifdef SIGHUP
signal( SIGHUP, exit_on_signal );
#endif
init_signals( exit_on_signal );
init_argv0_dir( argv[0] );
/* First rebuild the commandline to put in destination */

View File

@ -26,7 +26,6 @@
#include <string.h>
#include <assert.h>
#include <ctype.h>
#include <signal.h>
#include <limits.h>
#include <sys/types.h>
@ -396,11 +395,7 @@ int main(int argc,char *argv[])
{
int i;
signal( SIGTERM, exit_on_signal );
signal( SIGINT, exit_on_signal );
#ifdef SIGHUP
signal( SIGHUP, exit_on_signal );
#endif
init_signals( exit_on_signal );
init_argv0_dir( argv[0] );
/* Set the default defined stuff */