X-Git-Url: https://git.cworth.org/git?p=gzip;a=blobdiff_plain;f=gzip.c;h=b45fc88fa442f927192568cee8ba442ad6453ef4;hp=affde9eb386166150d410354e554b715c9520bc7;hb=47dc1883f1f730f9576ae0e6090ead01732ff4ff;hpb=0769cf77a953ca3d393b569e13a0c503f9fe7e44 diff --git a/gzip.c b/gzip.c index affde9e..b45fc88 100644 --- a/gzip.c +++ b/gzip.c @@ -233,6 +233,30 @@ unsigned inptr; /* index of next byte to be processed in inbuf */ unsigned outcnt; /* bytes in output buffer */ int rsync = 0; /* make ryncable chunks */ +static int handled_sig[] = + { + /* SIGINT must be first, as 'foreground' depends on it. */ + SIGINT + +#ifdef SIGHUP + , SIGHUP +#endif +#ifdef SIGPIPE + , SIGPIPE +#else +# define SIGPIPE 0 +#endif +#ifdef SIGTERM + , SIGTERM +#endif +#ifdef SIGXCPU + , SIGXCPU +#endif +#ifdef SIGXFSZ + , SIGXFSZ +#endif + }; + struct option longopts[] = { /* { name has_arg *flag val } */ @@ -1760,30 +1784,7 @@ local void treat_dir (fd, dir) static void install_signal_handlers () { - static int sig[] = - { - /* SIGINT must be first, as 'foreground' depends on it. */ - SIGINT - -#ifdef SIGHUP - , SIGHUP -#endif -#ifdef SIGPIPE - , SIGPIPE -#else -# define SIGPIPE 0 -#endif -#ifdef SIGTERM - , SIGTERM -#endif -#ifdef SIGXCPU - , SIGXCPU -#endif -#ifdef SIGXFSZ - , SIGXFSZ -#endif - }; - int nsigs = sizeof sig / sizeof sig[0]; + int nsigs = sizeof handled_sig / sizeof handled_sig[0]; int i; #if SA_NOCLDSTOP @@ -1792,9 +1793,9 @@ install_signal_handlers () sigemptyset (&caught_signals); for (i = 0; i < nsigs; i++) { - sigaction (sig[i], NULL, &act); + sigaction (handled_sig[i], NULL, &act); if (act.sa_handler != SIG_IGN) - sigaddset (&caught_signals, sig[i]); + sigaddset (&caught_signals, handled_sig[i]); } act.sa_handler = abort_gzip_signal; @@ -1802,20 +1803,20 @@ install_signal_handlers () act.sa_flags = 0; for (i = 0; i < nsigs; i++) - if (sigismember (&caught_signals, sig[i])) + if (sigismember (&caught_signals, handled_sig[i])) { if (i == 0) foreground = 1; - sigaction (sig[i], &act, NULL); + sigaction (handled_sig[i], &act, NULL); } #else for (i = 0; i < nsigs; i++) - if (signal (sig[i], SIG_IGN) != SIG_IGN) + if (signal (handled_sig[i], SIG_IGN) != SIG_IGN) { if (i == 0) foreground = 1; - signal (sig[i], abort_gzip_signal); - siginterrupt (sig[i], 1); + signal (handled_sig[i], abort_gzip_signal); + siginterrupt (handled_sig[i], 1); } #endif }