Lines Matching refs:sig

51 static void evsignal_handler(int sig);
78 0, base->sig.ev_signal_pair) == -1) {
83 base->sig.sh_old = NULL;
84 base->sig.sh_old_max = 0;
85 base->sig.evsignal_caught = 0;
86 memset(&base->sig.evsigcaught, 0, sizeof(sig_atomic_t)*NSIG);
89 TAILQ_INIT(&base->sig.evsigevents[i]);
91 event_set(&base->sig.ev_signal, base->sig.ev_signal_pair[1],
92 EV_READ | EV_PERSIST, evsignal_cb, &base->sig.ev_signal);
93 base->sig.ev_signal.ev_base = base;
94 base->sig.ev_signal.ev_flags |= EVLIST_INTERNAL;
106 struct evsignal_info *sig = &base->sig;
113 if (evsignal >= sig->sh_old_max) {
116 __func__, evsignal, sig->sh_old_max));
117 p = reallocarray(sig->sh_old, new_max, sizeof(*sig->sh_old));
123 memset((char *)p + sig->sh_old_max * sizeof(*sig->sh_old),
124 0, (new_max - sig->sh_old_max) * sizeof(*sig->sh_old));
126 sig->sh_old_max = new_max;
127 sig->sh_old = p;
131 sig->sh_old[evsignal] = malloc(sizeof *sig->sh_old[evsignal]);
132 if (sig->sh_old[evsignal] == NULL) {
143 if (sigaction(evsignal, &sa, sig->sh_old[evsignal]) == -1) {
145 free(sig->sh_old[evsignal]);
146 sig->sh_old[evsignal] = NULL;
158 struct evsignal_info *sig = &ev->ev_base->sig;
164 if (TAILQ_EMPTY(&sig->evsigevents[evsignal])) {
173 if (!sig->ev_signal_added) {
174 if (event_add(&sig->ev_signal, NULL))
176 sig->ev_signal_added = 1;
181 TAILQ_INSERT_TAIL(&sig->evsigevents[evsignal], ev, ev_signal_next);
190 struct evsignal_info *sig = &base->sig;
194 sh = sig->sh_old[evsignal];
195 sig->sh_old[evsignal] = NULL;
209 struct evsignal_info *sig = &base->sig;
215 TAILQ_REMOVE(&sig->evsigevents[evsignal], ev, ev_signal_next);
217 if (!TAILQ_EMPTY(&sig->evsigevents[evsignal]))
226 evsignal_handler(int sig)
233 __func__, sig);
237 evsignal_base->sig.evsigcaught[sig]++;
238 evsignal_base->sig.evsignal_caught = 1;
241 send(evsignal_base->sig.ev_signal_pair[0], "a", 1, 0);
248 struct evsignal_info *sig = &base->sig;
253 base->sig.evsignal_caught = 0;
255 ncalls = sig->evsigcaught[i];
258 sig->evsigcaught[i] -= ncalls;
260 for (ev = TAILQ_FIRST(&sig->evsigevents[i]);
275 if (base->sig.ev_signal_added) {
276 event_del(&base->sig.ev_signal);
277 base->sig.ev_signal_added = 0;
280 if (i < base->sig.sh_old_max && base->sig.sh_old[i] != NULL)
284 if (base->sig.ev_signal_pair[0] != -1) {
285 close(base->sig.ev_signal_pair[0]);
286 base->sig.ev_signal_pair[0] = -1;
288 if (base->sig.ev_signal_pair[1] != -1) {
289 close(base->sig.ev_signal_pair[1]);
290 base->sig.ev_signal_pair[1] = -1;
292 base->sig.sh_old_max = 0;
295 if (base->sig.sh_old) {
296 free(base->sig.sh_old);
297 base->sig.sh_old = NULL;