Lines Matching refs:sig
68 static void evsignal_handler(int sig);
106 AF_UNIX, SOCK_STREAM, 0, base->sig.ev_signal_pair) == -1) {
117 FD_CLOSEONEXEC(base->sig.ev_signal_pair[0]);
118 FD_CLOSEONEXEC(base->sig.ev_signal_pair[1]);
119 base->sig.sh_old = NULL;
120 base->sig.sh_old_max = 0;
121 base->sig.evsignal_caught = 0;
122 memset(&base->sig.evsigcaught, 0, sizeof(sig_atomic_t)*NSIG);
125 TAILQ_INIT(&base->sig.evsigevents[i]);
127 evutil_make_socket_nonblocking(base->sig.ev_signal_pair[0]);
129 event_set(&base->sig.ev_signal, base->sig.ev_signal_pair[1],
130 EV_READ | EV_PERSIST, evsignal_cb, &base->sig.ev_signal);
131 base->sig.ev_signal.ev_base = base;
132 base->sig.ev_signal.ev_flags |= EVLIST_INTERNAL;
148 struct evsignal_info *sig = &base->sig;
155 if (evsignal >= sig->sh_old_max) {
158 __func__, evsignal, sig->sh_old_max));
159 p = realloc(sig->sh_old, new_max * sizeof(*sig->sh_old));
165 memset((char *)p + sig->sh_old_max * sizeof(*sig->sh_old),
166 0, (new_max - sig->sh_old_max) * sizeof(*sig->sh_old));
168 sig->sh_old_max = new_max;
169 sig->sh_old = p;
173 sig->sh_old[evsignal] = malloc(sizeof *sig->sh_old[evsignal]);
174 if (sig->sh_old[evsignal] == NULL) {
186 if (sigaction(evsignal, &sa, sig->sh_old[evsignal]) == -1) {
188 free(sig->sh_old[evsignal]);
194 free(sig->sh_old[evsignal]);
197 *sig->sh_old[evsignal] = sh;
208 struct evsignal_info *sig = &ev->ev_base->sig;
214 if (TAILQ_EMPTY(&sig->evsigevents[evsignal])) {
223 if (!sig->ev_signal_added) {
224 if (event_add(&sig->ev_signal, NULL))
226 sig->ev_signal_added = 1;
231 TAILQ_INSERT_TAIL(&sig->evsigevents[evsignal], ev, ev_signal_next);
240 struct evsignal_info *sig = &base->sig;
248 sh = sig->sh_old[evsignal];
249 sig->sh_old[evsignal] = NULL;
270 struct evsignal_info *sig = &base->sig;
276 TAILQ_REMOVE(&sig->evsigevents[evsignal], ev, ev_signal_next);
278 if (!TAILQ_EMPTY(&sig->evsigevents[evsignal]))
287 evsignal_handler(int sig)
294 __func__, sig);
298 evsignal_base->sig.evsigcaught[sig]++;
299 evsignal_base->sig.evsignal_caught = 1;
302 signal(sig, evsignal_handler);
306 send(evsignal_base->sig.ev_signal_pair[0], "a", 1, 0);
313 struct evsignal_info *sig = &base->sig;
318 base->sig.evsignal_caught = 0;
320 ncalls = sig->evsigcaught[i];
323 sig->evsigcaught[i] -= ncalls;
325 for (ev = TAILQ_FIRST(&sig->evsigevents[i]);
340 if (base->sig.ev_signal_added) {
341 event_del(&base->sig.ev_signal);
342 base->sig.ev_signal_added = 0;
345 if (i < base->sig.sh_old_max && base->sig.sh_old[i] != NULL)
349 EVUTIL_CLOSESOCKET(base->sig.ev_signal_pair[0]);
350 base->sig.ev_signal_pair[0] = -1;
351 EVUTIL_CLOSESOCKET(base->sig.ev_signal_pair[1]);
352 base->sig.ev_signal_pair[1] = -1;
353 base->sig.sh_old_max = 0;
356 free(base->sig.sh_old);