dload: prevent need to copy struct in mask_signal()

Since we store this directly in the download function, just rework
mask_signal() to take a pointer to a location to store the original.

Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
Dan McGee 2011-08-22 09:27:13 -05:00
parent f3e2858621
commit 762cbf574b
1 changed files with 6 additions and 7 deletions

View File

@ -220,18 +220,17 @@ static void curl_set_handle_opts(struct dload_payload *payload,
}
}
static struct sigaction mask_signal(int signal, void (*handler)(int))
static void mask_signal(int signal, void (*handler)(int),
struct sigaction *origaction)
{
struct sigaction newaction, origaction;
struct sigaction newaction;
newaction.sa_handler = handler;
sigemptyset(&newaction.sa_mask);
newaction.sa_flags = 0;
sigaction(signal, NULL, &origaction);
sigaction(signal, NULL, origaction);
sigaction(signal, &newaction, NULL);
return origaction;
}
static void unmask_signal(int signal, struct sigaction sa)
@ -319,8 +318,8 @@ static int curl_download_internal(struct dload_payload *payload,
/* ignore any SIGPIPE signals- these may occur if our FTP socket dies or
* something along those lines. Store the old signal handler first. */
orig_sig_pipe = mask_signal(SIGPIPE, SIG_IGN);
orig_sig_int = mask_signal(SIGINT, &inthandler);
mask_signal(SIGPIPE, SIG_IGN, &orig_sig_pipe);
mask_signal(SIGINT, &inthandler, &orig_sig_int);
/* Progress 0 - initialize */
prevprogress = 0;