85
81
/* The last #include file should be: */
86
82
#include "memdebug.h"
89
struct sigpipe_ignore {
90
struct sigaction old_pipe_act;
94
#define SIGPIPE_VARIABLE(x) struct sigpipe_ignore x
97
* sigpipe_ignore() makes sure we ignore SIGPIPE while running libcurl
98
* internals, and then sigpipe_restore() will restore the situation when we
99
* return from libcurl again.
101
static void sigpipe_ignore(struct SessionHandle *data,
102
struct sigpipe_ignore *ig)
104
/* get a local copy of no_signal because the SessionHandle might not be
105
around when we restore */
106
ig->no_signal = data->set.no_signal;
107
if(!data->set.no_signal) {
108
struct sigaction action;
109
/* first, extract the existing situation */
110
memset(&ig->old_pipe_act, 0, sizeof(struct sigaction));
111
sigaction(SIGPIPE, NULL, &ig->old_pipe_act);
112
action = ig->old_pipe_act;
113
/* ignore this signal */
114
action.sa_handler = SIG_IGN;
115
sigaction(SIGPIPE, &action, NULL);
120
* sigpipe_restore() puts back the outside world's opinion of signal handler
121
* and SIGPIPE handling. It MUST only be called after a corresponding
122
* sigpipe_ignore() was used.
124
static void sigpipe_restore(struct sigpipe_ignore *ig)
127
/* restore the outside state */
128
sigaction(SIGPIPE, &ig->old_pipe_act, NULL);
132
/* for systems without sigaction */
133
#define sigpipe_ignore(x,y) Curl_nop_stmt
134
#define sigpipe_restore(x) Curl_nop_stmt
135
#define SIGPIPE_VARIABLE(x)
138
84
/* win32_cleanup() is for win32 socket cleanup functionality, the opposite
139
85
of win32_init() */
140
86
static void win32_cleanup(void)