8000 libevent/signal.c at master · TitanJP/libevent · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
< 8000 script type="application/json" data-target="react-app.embeddedData">{"payload":{"allShortcutsEnabled":false,"fileTree":{"":{"items":[{"name":"WIN32-Code","path":"WIN32-Code","contentType":"directory"},{"name":"cmake","path":"cmake","contentType":"directory"},{"name":"compat","path":"compat","contentType":"directory"},{"name":"include","path":"include","contentType":"directory"},{"name":"m4","path":"m4","contentType":"directory"},{"name":"sample","path":"sample","contentType":"directory"},{"name":"test","path":"test","contentType":"directory"},{"name":".gitignore","path":".gitignore","contentType":"file"},{"name":".travis.yml","path":".travis.yml","contentType":"file"},{"name":"CMakeLists.txt","path":"CMakeLists.txt","contentType":"file"},{"name":"ChangeLog","path":"ChangeLog","contentType":"file"},{"name":"ChangeLog-1.4","path":"ChangeLog-1.4","contentType":"file"},{"name":"ChangeLog-2.0","path":"ChangeLog-2.0","contentType":"file"},{"name":"Doxyfile","path":"Doxyfile","contentType":"file"},{"name":"LICENSE","path":"LICENSE","contentType":"file"},{"name":"Makefile.am","path":"Makefile.am","contentType":"file"},{"name":"Makefile.nmake","path":"Makefile.nmake","contentType":"file"},{"name":"README.md","path":"README.md","contentType":"file"},{"name":"appveyor.yml","path":"appveyor.yml","contentType":"file"},{"name":"arc4random.c","path":"arc4random.c","contentType":"file"},{"name":"autogen.sh","path":"autogen.sh","contentType":"file"},{"name":"buffer.c","path":"buffer.c","contentType":"file"},{"name":"buffer_iocp.c","path":"buffer_iocp.c","contentType":"file"},{"name":"bufferevent-internal.h","path":"bufferevent-internal.h","contentType":"file"},{"name":"bufferevent.c","path":"bufferevent.c","contentType":"file"},{"name":"bufferevent_async.c","path":"bufferevent_async.c","contentType":"file"},{"name":"bufferevent_filter.c","path":"bufferevent_filter.c","contentType":"file"},{"name":"bufferevent_openssl.c","path":"bufferevent_openssl.c","contentType":"file"},{"name":"bufferevent_pair.c","path":"bufferevent_pair.c","contentType":"file"},{"name":"bufferevent_ratelim.c","path":"bufferevent_ratelim.c","contentType":"file"},{"name":"bufferevent_sock.c","path":"bufferevent_sock.c","contentType":"file"},{"name":"changelist-internal.h","path":"changelist-internal.h","contentType":"file"},{"name":"configure.ac","path":"configure.ac","contentType":"file"},{"name":"defer-internal.h","path":"defer-internal.h","contentType":"file"},{"name":"devpoll.c","path":"devpoll.c","contentType":"file"},{"name":"epoll.c","path":"epoll.c","contentType":"file"},{"name":"epoll_sub.c","path":"epoll_sub.c","contentType":"file"},{"name":"epolltable-internal.h","path":"epolltable-internal.h","contentType":"file"},{"name":"evbuffer-internal.h","path":"evbuffer-internal.h","contentType":"file"},{"name":"evconfig-private.h.cmake","path":"evconfig-private.h.cmake","contentType":"file"},{"name":"evconfig-private.h.in","path":"evconfig-private.h.in","contentType":"file"},{"name":"evdns.3","path":"evdns.3","contentType":"file"},{"name":"evdns.c","path":"evdns.c","contentType":"file"},{"name":"event-config.h.cmake","path":"event-config.h.cmake","contentType":"file"},{"name":"event-internal.h","path":"event-internal.h","contentType":"file"},{"name":"event.3","path":"event.3","contentType":"file"},{"name":"event.c","path":"event.c","contentType":"file"},{"name":"event_iocp.c","path":"event_iocp.c","contentType":"file"},{"name":"event_rpcgen.py","path":"event_rpcgen.py","contentType":"file"},{"name":"event_tagging.c","path":"event_tagging.c","contentType":"file"},{"name":"evmap-internal.h","path":"evmap-internal.h","contentType":"file"},{"name":"evmap.c","path":"evmap.c","contentType":"file"},{"name":"evport.c","path":"evport.c","contentType":"file"},{"name":"evrpc-internal.h","path":"evrpc-internal.h","contentType":"file"},{"name":"evrpc.c","path":"evrpc.c","contentType":"file"},{"name":"evsignal-internal.h","path":"evsignal-internal.h","contentType":"file"},{"name":"evthread-internal.h","path":"evthread-internal.h","contentType":"file"},{"name":"evthread.c","path":"evthread.c","contentType":"file"},{"name":"evthread_pthread.c","path":"evthread_pthread.c","contentType":"file"},{"name":"evthread_win32.c","path":"evthread_win32.c","contentType":"file"},{"name":"evutil.c","path":"evutil.c","contentType":"file"},{"name":"evutil_rand.c","path":"evutil_rand.c","contentType":"file"},{"name":"evutil_time.c","path":"evutil_time.c","contentType":"file"},{"name":"ht-internal.h","path":"ht-internal.h","contentType":"file"},{"name":"http-internal.h","path":"http-internal.h","contentType":"file"},{"name":"http.c","path":"http.c","contentType":"file"},{"name":"iocp-internal.h","path":"iocp-internal.h","contentType":"file"},{"name":"ipv6-internal.h","path":"ipv6-internal.h","contentType":"file"},{"name":"kqueue-internal.h","path":"kqueue-internal.h","contentType":"file"},{"name":"kqueue.c","path":"kqueue.c","contentType":"file"},{"name":"libevent.pc.in","path":"libevent.pc.in","contentType":"file"},{"name":"libevent_core.pc.in","path":"libevent_core.pc.in","contentType":"file"},{"name":"libevent_extra.pc.in","path":"libevent_extra.pc.in","contentType":"file"},{"name":"libevent_openssl.pc.in","path":"libevent_openssl.pc.in","contentType":"file"},{"name":"libevent_pthreads.pc.in","path":"libevent_pthreads.pc.in","contentType":"file"},{"name":"listener.c","path":"listener.c","contentType":"file"},{"name":"log-internal.h","path":"log-internal.h","contentType":"file"},{"name":"log.c","path":"log.c","contentType":"file"},{"name":"make-event-config.sed","path":"make-event-config.sed","contentType":"file"},{"name":"make_epoll_table.py","path":"make_epoll_table.py","contentType":"file"},{"name":"minheap-internal.h","path":"minheap-internal.h","contentType":"file"},{"name":"mm-internal.h","path":"mm-internal.h","contentType":"file"},{"name":"poll.c","path":"poll.c","contentType":"file"},{"name":"ratelim-internal.h","path":"ratelim-internal.h","contentType":"file"},{"name":"select.c","path":"select.c","contentType":"file"},{"name":"signal.c","path":"signal.c","contentType":"file"},{"name":"strlcpy-internal.h","path":"strlcpy-internal.h","contentType":"file"},{"name":"strlcpy.c","path":"strlcpy.c","contentType":"file"},{"name":"time-internal.h","path":"time-internal.h","contentType":"file"},{"name":"util-internal.h","path":"util-internal.h","contentType":"file"},{"name":"whatsnew-2.0.txt","path":"whatsnew-2.0.txt","contentType":"file"},{"name":"whatsnew-2.1.txt","path":"whatsnew-2.1.txt","contentType":"file"},{"name":"win32select.c","path":"win32select.c","contentType":"file"}],"totalCount":93}},"fileTreeProcessingTime":4.098756,"foldersToFetch":[],"incompleteFileTree":false,"repo":{"id":67355003,"defaultBranch":"master","name":"libevent","ownerLogin":"TitanJP","currentUserCanPush":false,"isFork":true,"isEmpty":false,"createdAt":"2016-09-04T16:08:27.000Z","ownerAvatar":"https://avatars.githubusercontent.com/u/8065086?v=4","public":true,"private":false,"isOrgOwned":false},"codeLineWrapEnabled":false,"symbolsExpanded":false,"treeExpanded":true,"refInfo":{"name":"master","listCacheKey":"v0:1615065036.9825878","canEdit":false,"refType":"branch","currentOid":"a73fb2f443ebf9687ee6ca81a6401d1f3751683f"},"path":"signal.c","currentUser":null,"blob":{"rawLines":["/*\t$OpenBSD: select.c,v 1.2 2002/06/25 15:50:15 mickey Exp $\t*/","","/*"," * Copyright 2000-2007 Niels Provos \u003cprovos@citi.umich.edu\u003e"," * Copyright 2007-2012 Niels Provos and Nick Mathewson"," *"," * Redistribution and use in source and binary forms, with or without"," * modification, are permitted provided that the following conditions"," * are met:"," * 1. Redistributions of source code must retain the above copyright"," * notice, this list of conditions and the following disclaimer."," * 2. Redistributions in binary form must reproduce the above copyright"," * notice, this list of conditions and the following disclaimer in the"," * documentation and/or other materials provided with the distribution."," * 3. The name of the author may not be used to endorse or promote products"," * derived from this software without specific prior written permission."," *"," * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR"," * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES"," * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED."," * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,"," * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT"," * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,"," * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY"," * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT"," * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF"," * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."," */","#include \"event2/event-config.h\"","#include \"evconfig-private.h\"","","#ifdef _WIN32","#define WIN32_LEAN_AND_MEAN","#include \u003cwinsock2.h\u003e","#include \u003cwindows.h\u003e","#undef WIN32_LEAN_AND_MEAN","#endif","#include \u003csys/types.h\u003e","#ifdef EVENT__HAVE_SYS_TIME_H","#include \u003csys/time.h\u003e","#endif","#include \u003csys/queue.h\u003e","#ifdef EVENT__HAVE_SYS_SOCKET_H","#include \u003csys/socket.h\u003e","#endif","#include \u003csignal.h\u003e","#include \u003cstdio.h\u003e","#include \u003cstdlib.h\u003e","#include \u003cstring.h\u003e","#ifdef EVENT__HAVE_UNISTD_H","#include \u003cunistd.h\u003e","#endif","#include \u003cerrno.h\u003e","#ifdef EVENT__HAVE_FCNTL_H","#include \u003cfcntl.h\u003e","#endif","","#include \"event2/event.h\"","#include \"event2/event_struct.h\"","#include \"event-internal.h\"","#include \"event2/util.h\"","#include \"evsignal-internal.h\"","#include \"log-internal.h\"","#include \"evmap-internal.h\"","#include \"evthread-internal.h\"","","/*"," signal.c",""," This is the signal-handling implementation we use for backends that don't"," have a better way to do signal handling. It uses sigaction() or signal()"," to set a signal handler, and a socket pair to tell the event base when",""," Note that I said \"the event base\" : only one event base can be set up to use"," this at a time. For historical reasons and backward compatibility, if you"," add an event for a signal to event_base A, then add an event for a signal"," (any signal!) to event_base B, event_base B will get informed about the"," signal, but event_base A won't.",""," It would be neat to change this behavior in some future version of Libevent."," kqueue already does something far more sensible. We can make all backends"," on Linux do a reasonable thing using signalfd.","*/","","#ifndef _WIN32","/* Windows wants us to call our signal handlers as __cdecl. Nobody else"," * expects you to do anything crazy like this. */","#define __cdecl","#endif","","static int evsig_add(struct event_base *, evutil_socket_t, short, short, void *);","static int evsig_del(struct event_base *, evutil_socket_t, short, short, void *);","","static const struct eventop evsigops = {","\t\"signal\",","\tNULL,","\tevsig_add,","\tevsig_del,","\tNULL,","\tNULL,","\t0, 0, 0","};","","#ifndef EVENT__DISABLE_THREAD_SUPPORT","/* Lock for evsig_base and evsig_base_n_signals_added fields. */","static void *evsig_base_lock = NULL;","#endif","/* The event base that's currently getting informed about signals. */","static struct event_base *evsig_base = NULL;","/* A copy of evsig_base-\u003esigev_n_signals_added. */","static int evsig_base_n_signals_added = 0;","static evutil_socket_t evsig_base_fd = -1;","","static void __cdecl evsig_handler(int sig);","","#define EVSIGBASE_LOCK() EVLOCK_LOCK(evsig_base_lock, 0)","#define EVSIGBASE_UNLOCK() EVLOCK_UNLOCK(evsig_base_lock, 0)","","void","evsig_set_base_(struct event_base *base)","{","\tEVSIGBASE_LOCK();","\tevsig_base = base;","\tevsig_base_n_signals_added = base-\u003esig.ev_n_signals_added;","\tevsig_base_fd = base-\u003esig.ev_signal_pair[1];","\tEVSIGBASE_UNLOCK();","}","","/* Callback for when the signal handler write a byte to our signaling socket */","static void","evsig_cb(evutil_socket_t fd, short what, void *arg)","{","\tstatic char signals[1024];","\tev_ssize_t n;","\tint i;","\tint ncaught[NSIG];","\tstruct event_base *base;","","\tbase = arg;","","\tmemset(\u0026ncaught, 0, sizeof(ncaught));","","\twhile (1) {","#ifdef _WIN32","\t\tn = recv(fd, signals, sizeof(signals), 0);","#else","\t\tn = read(fd, signals, sizeof(signals));","#endif","\t\tif (n == -1) {","\t\t\tint err = evutil_socket_geterror(fd);","\t\t\tif (! EVUTIL_ERR_RW_RETRIABLE(err))","\t\t\t\tevent_sock_err(1, fd, \"%s: recv\", __func__);","\t\t\tbreak;","\t\t} else if (n == 0) {","\t\t\t/* XXX warn? */","\t\t\tbreak;","\t\t}","\t\tfor (i = 0; i \u003c n; ++i) {","\t\t\tev_uint8_t sig = signals[i];","\t\t\tif (sig \u003c NSIG)","\t\t\t\tncaught[sig]++;","\t\t}","\t}","","\tEVBASE_ACQUIRE_LOCK(base, th_base_lock);","\tfor (i = 0; i \u003c NSIG; ++i) {","\t\tif (ncaught[i])","\t\t\tevmap_signal_active_(base, i, ncaught[i]);","\t}","\tEVBASE_RELEASE_LOCK(base, th_base_lock);","}","","int","evsig_init_(struct event_base *base)","{","\t/*","\t * Our signal handler is going to write to one end of the socket","\t * pair to wake up our event loop. The event loop then scans for","\t * signals that got delivered.","\t */","\tif (evutil_make_internal_pipe_(base-\u003esig.ev_signal_pair) == -1) {","#ifdef _WIN32","\t\t/* Make this nonfatal on win32, where sometimes people","\t\t have localhost firewalled. */","\t\tevent_sock_warn(-1, \"%s: socketpair\", __func__);","#else","\t\tevent_sock_err(1, -1, \"%s: socketpair\", __func__);","#endif","\t\treturn -1;","\t}","","\tif (base-\u003esig.sh_old) {","\t\tmm_free(base-\u003esig.sh_old);","\t}","\tbase-\u003esig.sh_old = NULL;","\tbase-\u003esig.sh_old_max = 0;","","\tevent_assign(\u0026base-\u003esig.ev_signal, base, base-\u003esig.ev_signal_pair[0],","\t\tEV_READ | EV_PERSIST, evsig_cb, base);","","\tbase-\u003esig.ev_signal.ev_flags |= EVLIST_INTERNAL;","\tevent_priority_set(\u0026base-\u003esig.ev_signal, 0);","","\tbase-\u003eevsigsel = \u0026evsigops;","","\treturn 0;","}","","/* Helper: set the signal handler for evsignal to handler in base, so that"," * we can restore the original handler when we clear the current one. */","int","evsig_set_handler_(struct event_base *base,"," int evsignal, void (__cdecl *handler)(int))","{","#ifdef EVENT__HAVE_SIGACTION","\tstruct sigaction sa;","#else","\tev_sighandler_t sh;","#endif","\tstruct evsig_info *sig = \u0026base-\u003esig;","\tvoid *p;","","\t/*","\t * resize saved signal handler array up to the highest signal number.","\t * a dynamic array is used to keep footprint on the low side.","\t */","\tif (evsignal \u003e= sig-\u003esh_old_max) {","\t\tint new_max = evsignal + 1;","\t\tevent_debug((\"%s: evsignal (%d) \u003e= sh_old_max (%d), resizing\",","\t\t\t __func__, evsignal, sig-\u003esh_old_max));","\t\tp = mm_realloc(sig-\u003esh_old, new_max * sizeof(*sig-\u003esh_old));","\t\tif (p == NULL) {","\t\t\tevent_warn(\"realloc\");","\t\t\treturn (-1);","\t\t}","","\t\tmemset((char *)p + sig-\u003esh_old_max * sizeof(*sig-\u003esh_old),","\t\t 0, (new_max - sig-\u003esh_old_max) * sizeof(*sig-\u003esh_old));","","\t\tsig-\u003esh_old_max = new_max;","\t\tsig-\u003esh_old = p;","\t}","","\t/* allocate space for previous handler out of dynamic array */","\tsig-\u003esh_old[evsignal] = mm_malloc(sizeof *sig-\u003esh_old[evsignal]);","\tif (sig-\u003esh_old[evsignal] == NULL) {","\t\tevent_warn(\"malloc\");","\t\treturn (-1);","\t}","","\t/* save previous handler and setup new handler */","#ifdef EVENT__HAVE_SIGACTION","\tmemset(\u0026sa, 0, sizeof(sa));","\tsa.sa_handler = handler;","\tsa.sa_flags |= SA_RESTART;","\tsigfillset(\u0026sa.sa_mask);","","\tif (sigaction(evsignal, \u0026sa, sig-\u003esh_old[evsignal]) == -1) {","\t\tevent_warn(\"sigaction\");","\t\tmm_free(sig-\u003esh_old[evsignal]);","\t\tsig-\u003esh_old[evsignal] = NULL;","\t\treturn (-1);","\t}","#else","\tif ((sh = signal(evsignal, handler)) == SIG_ERR) {","\t\tevent_warn(\"signal\");","\t\tmm_free(sig-\u003esh_old[evsignal]);","\t\tsig-\u003esh_old[evsignal] = NULL;","\t\treturn (-1);","\t}","\t*sig-\u003esh_old[evsignal] = sh;","#endif","","\treturn (0);","}","","static int","evsig_add(struct event_base *base, evutil_socket_t evsignal, short old, short events, void *p)","{","\tstruct evsig_info *sig = \u0026base-\u003esig;","\t(void)p;","","\tEVUTIL_ASSERT(evsignal \u003e= 0 \u0026\u0026 evsignal \u003c NSIG);","","\t/* catch signals if they happen quickly */","\tEVSIGBASE_LOCK();","\tif (evsig_base != base \u0026\u0026 evsig_base_n_signals_added) {","\t\tevent_warnx(\"Added a signal to event base %p with signals \"","\t\t \"already added to event_base %p. Only one can have \"","\t\t \"signals at a time with the %s backend. The base with \"","\t\t \"the most recently added signal or the most recent \"","\t\t \"event_base_loop() call gets preference; do \"","\t\t \"not rely on this behavior in future Libevent versions.\",","\t\t base, evsig_base, base-\u003eevsel-\u003ename);","\t}","\tevsig_base = base;","\tevsig_base_n_signals_added = ++sig-\u003eev_n_signals_added;","\tevsig_base_fd = base-\u003esig.ev_signal_pair[1];","\tEVSIGBASE_UNLOCK();","","\tevent_debug((\"%s: %d: changing signal handler\", __func__, (int)evsignal));","\tif (evsig_set_handler_(base, (int)evsignal, evsig_handler) == -1) {","\t\tgoto err;","\t}","","","\tif (!sig-\u003eev_signal_added) {","\t\tif (event_add_nolock_(\u0026sig-\u003eev_signal, NULL, 0))","\t\t\tgoto err;","\t\tsig-\u003eev_signal_added = 1;","\t}","","\treturn (0);","","err:","\tEVSIGBASE_LOCK();","\t--evsig_base_n_signals_added;","\t--sig-\u003eev_n_signals_added;","\tEVSIGBASE_UNLOCK();","\treturn (-1);","}","","int","evsig_restore_handler_(struct event_base *base, int evsignal)","{","\tint ret = 0;","\tstruct evsig_info *sig = \u0026base-\u003esig;","#ifdef EVENT__HAVE_SIGACTION","\tstruct sigaction *sh;","#else","\tev_sighandler_t *sh;","#endif","","\tif (evsignal \u003e= sig-\u003esh_old_max) {","\t\t/* Can't actually restore. */","\t\t/* XXXX.*/","\t\treturn 0;","\t}","","\t/* restore previous handler */","\tsh = sig-\u003esh_old[evsignal];","\tsig-\u003esh_old[evsignal] = NULL;","#ifdef EVENT__HAVE_SIGACTION","\tif (sigaction(evsignal, sh, NULL) == -1) {","\t\tevent_warn(\"sigaction\");","\t\tret = -1;","\t}","#else","\tif (signal(evsignal, *sh) == SIG_ERR) {","\t\tevent_warn(\"signal\");","\t\tret = -1;","\t}","#endif","","\tmm_free(sh);","","\treturn ret;","}","","static int","evsig_del(struct event_base *base, evutil_socket_t evsignal, short old, short events, void *p)","{","\tEVUTIL_ASSERT(evsignal \u003e= 0 \u0026\u0026 evsignal \u003c NSIG);","","\tevent_debug((\"%s: \"EV_SOCK_FMT\": restoring signal handler\",","\t\t__func__, EV_SOCK_ARG(evsignal)));","","\tEVSIGBASE_LOCK();","\t--evsig_base_n_signals_added;","\t--base-\u003esig.ev_n_signals_added;","\tEVSIGBASE_UNLOCK();","","\treturn (evsig_restore_handler_(base, (int)evsignal));","}","","static void __cdecl","evsig_handler(int sig)","{","\tint save_errno = errno;","#ifdef _WIN32","\tint socket_errno = EVUTIL_SOCKET_ERROR();","#endif","\tev_uint8_t msg;","","\tif (evsig_base == NULL) {","\t\tevent_warnx(","\t\t\t\"%s: received signal %d, but have no base configured\",","\t\t\t__func__, sig);","\t\treturn;","\t}","","#ifndef EVENT__HAVE_SIGACTION","\tsignal(sig, evsig_handler);","#endif","","\t/* Wake up our notification mechanism */","\tmsg = sig;","#ifdef _WIN32","\tsend(evsig_base_fd, (char*)\u0026msg, 1, 0);","#else","\t{","\t\tint r = write(evsig_base_fd, (char*)\u0026msg, 1);","\t\t(void)r; /* Suppress 'unused return value' and 'unused var' */","\t}","#endif","\terrno = save_errno;","#ifdef _WIN32","\tEVUTIL_SET_SOCKET_ERROR(socket_errno);","#endif","}","","void","evsig_dealloc_(struct event_base *base)","{","\tint i = 0;","\tif (base-\u003esig.ev_signal_added) {","\t\tevent_del(\u0026base-\u003esig.ev_signal);","\t\tbase-\u003esig.ev_signal_added = 0;","\t}","\t/* debug event is created in evsig_init_/event_assign even when","\t * ev_signal_added == 0, so unassign is required */","\tevent_debug_unassign(\u0026base-\u003esig.ev_signal);","","\tfor (i = 0; i \u003c NSIG; ++i) {","\t\tif (i \u003c base-\u003esig.sh_old_max \u0026\u0026 base-\u003esig.sh_old[i] != NULL)","\t\t\tevsig_restore_handler_(base, i);","\t}","\tEVSIGBASE_LOCK();","\tif (base == evsig_base) {","\t\tevsig_base = NULL;","\t\tevsig_base_n_signals_added = 0;","\t\tevsig_base_fd = -1;","\t}","\tEVSIGBASE_UNLOCK();","","\tif (base-\u003esig.ev_signal_pair[0] != -1) {","\t\tevutil_closesocket(base-\u003esig.ev_signal_pair[0]);","\t\tbase-\u003esig.ev_signal_pair[0] = -1;","\t}","\tif (base-\u003esig.ev_signal_pair[1] != -1) {","\t\tevutil_closesocket(base-\u003esig.ev_signal_pair[1]);","\t\tbase-\u003esig.ev_signal_pair[1] = -1;","\t}","\tbase-\u003esig.sh_old_max = 0;","","\t/* per index frees are handled in evsig_del() */","\tif (base-\u003esig.sh_old) {","\t\tmm_free(base-\u003esig.sh_old);","\t\tbase-\u003esig.sh_old = NULL;","\t}","}","","static void","evsig_free_globals_locks(void)","{","#ifndef EVENT__DISABLE_THREAD_SUPPORT","\tif (evsig_base_lock != NULL) {","\t\tEVTHREAD_FREE_LOCK(evsig_base_lock, 0);","\t\tevsig_base_lock = NULL;","\t}","#endif","\treturn;","}","","void","evsig_free_globals_(void)","{","\tevsig_free_globals_locks();","}","","#ifndef EVENT__DISABLE_THREAD_SUPPORT","int","evsig_global_setup_locks_(const int enable_locks)","{","\tEVTHREAD_SETUP_GLOBAL_LOCK(evsig_base_lock, 0);","\treturn 0;","}","","#endif"],"stylingDirectives":null,"colorizedLines":null,"csv":null,"csvError":null,"dependabotInfo":{"showConfigurationBanner":false,"configFilePath":null,"networkDependabotPath":"/TitanJP/libevent/network/updates","dismissConfigurationNoticePath":"/settings/dismiss-notice/dependabot_configuration_notice","configurationNoticeDismissed":null},"displayName":"signal.c","displayUrl":"https://github.com/TitanJP/libevent/blob/master/signal.c?raw=true","headerInfo":{"blobSize":"12.2 KB","deleteTooltip":"You must be signed in to make or propose changes","editTooltip":"You must be signed in to make or propose changes","ghDesktopPath":"https://desktop.github.com","isGitLfs":false,"onBranch":true,"shortPath":"3f46295","siteNavLoginPath":"/login?return_to=https%3A%2F%2Fgithub.com%2FTitanJP%2Flibevent%2Fblob%2Fmaster%2Fsignal.c","isCSV":false,"isRichtext":false,"toc":null,"lineInfo":{"truncatedLoc":"479","truncatedSloc":"417"},"mode":"file"},"image":false,"isCodeownersFile":null,"isPlain":false,"isValidLegacyIssueTemplate":false,"issueTemplate":null,"discussionTemplate":null,"language":"C","languageID":41,"large":false,"planSupportInfo":{"repoIsFork":null,"repoOwnedByCurrentUser":null,"requestFullPath":"/TitanJP/libevent/blob/master/signal.c","showFreeOrgGatedFeatureMessage":null,"showPlanSupportBanner":null,"upgradeDataAttributes":null,"upgradePath":null},"publishBannersInfo":{"dismissActionNoticePath":"/settings/dismiss-notice/publish_action_from_dockerfile","releasePath":"/TitanJP/libevent/releases/new?marketplace=true","showPublishActionBanner":false},"rawBlobUrl":"https://github.com/TitanJP/libevent/raw/refs/heads/master/signal.c","renderImageOrRaw":false,"richText":null,"renderedFileInfo":null,"shortPath":null,"symbolsEnabled":true,"tabSize":8,"topBannersInfo":{"overridingGlobalFundingFile":false,"globalPreferredFundingPath":null,"showInvalidCitationWarning":false,"citationHelpUrl":"https://docs.github.com/github/creating-cloning-and-archiving-repositories/creating-a-repository-on-github/about-citation-files","actionsOnboardingTip":null},"truncated":false,"viewable":true,"workflowRedirectUrl":null,"symbols":{"timed_out":false,"not_analyzed":false,"symbols":[{"name":"WIN32_LEAN_AND_MEAN","kind":"macro","ident_start":1675,"ident_end":1694,"extent_start":1667,"extent_end":1695,"fully_qualified_name":"WIN32_LEAN_AND_MEAN","ident_utf16":{"start":{"line_number":32,"utf16_col":8},"end":{"line_number":32,"utf16_col":27}},"extent_utf16":{"start":{"line_number":32,"utf16_col":0},"end":{"line_number":33,"utf16_col":0}}},{"name":"__cdecl","kind":"macro","ident_start":3313,"ident_end":3320,"extent_start":3305,"extent_end":3321,"fully_qualified_name":"__cdecl","ident_utf16":{"start":{"line_number":87,"utf16_col":8},"end":{"line_number":87,"utf16_col":15}},"extent_utf16":{"start":{"line_number":87,"utf16_col":0},"end":{"line_number":88,"utf16_col":0}}},{"name":"evsig_add","kind":"function","ident_start":3340,"ident_end":3349,"extent_start":3340,"extent_end":3409,"fully_qualified_name":"evsig_add","ident_utf16":{"start":{"line_number":90,"utf16_col":11},"end":{"line_number":90,"utf16_col":20}},"extent_utf16":{"start":{"line_number":90,"utf16_col":11},"end":{"line_number":90,"utf16_col":80}}},{"name":"evsig_del","kind":"function","ident_start":3422,"ident_end":3431,"extent_start":3422,"extent_end":3491,"fully_qualified_name":"evsig_del","ident_utf16":{"start":{"line_number":91,"utf16_col":11},"end":{"line_number":91,"utf16_col":20}},"extent_utf16":{"start":{"line_number":91,"utf16_col":11},"end":{"line_number":91,"utf16_col":80}}},{"name":"evsig_handler","kind":"function","ident_start":4024,"ident_end":4037,"extent_start":4024,"extent_end":4046,"fully_qualified_name":"evsig_handler","ident_utf16":{"start":{"line_number":113,"utf16_col":20},"end":{"line_number":113,"utf16_col":33}},"extent_utf16":{"start":{"line_number":113,"utf16_col":20},"end":{"line_number":113,"utf16_col":42}}},{"name":"evsig_set_base_","kind":"function","ident_start":4173,"ident_end":4188,"extent_start":4173,"extent_end":4213,"fully_qualified_name":"evsig_set_base_","ident_utf16":{"start":{"line_number":119,"utf16_col":0},"end":{"line_number":119,"utf16_col":15}},"extent_utf16":{"start":{"line_number":119,"utf16_col":0},"end":{"line_number":119,"utf16_col":40}}},{"name":"evsig_cb","kind":"function","ident_start":4477,"ident_end":4485,"extent_start":4477,"extent_end":4528,"fully_qualified_name":"evsig_cb","ident_utf16":{"start":{"line_number":130,"utf16_col":0},"end":{"line_number":130,"utf16_col":8}},"extent_utf16":{"start":{"line_number":130,"utf16_col":0},"end":{"line_number":130,"utf16_col":51}}},{"name":"evsig_init_","kind":"function","ident_start":5317,"ident_end":5328,"extent_start":5317,"extent_end":5353,"fully_qualified_name":"evsig_init_","ident_utf16":{"start":{"line_number":173,"utf16_col":0},"end":{"line_number":173,"utf16_col":11}},"extent_utf16":{"start":{"line_number":173,"utf16_col":0},"end":{"line_number":173,"utf16_col":36}}},{"name":"evsig_set_handler_","kind":"function","ident_start":6354,"ident_end":6372,"extent_start":6354,"extent_end":6445,"fully_qualified_name":"evsig_set_handler_","ident_utf16":{"start":{"line_number":211,"utf16_col":0},"end":{"line_number":211,"utf16_col":18}},"extent_utf16":{"start":{"line_number":211,"utf16_col":0},"end":{"line_number":212,"utf16_col":47}}},{"name":"evsig_add","kind":"function","ident_start":8013,"ident_end":8022,"extent_start":8013,"extent_end":8107,"fully_qualified_name":"evsig_add","ident_utf16":{"start":{"line_number":277,"utf16_col":0},"end":{"line_number":277,"utf16_col":9}},"extent_utf16":{"start":{"line_number":277,"utf16_col":0},"end":{"line_number":277,"utf16_col":94}}},{"name":"evsig_restore_handler_","kind":"function","ident_start":9309,"ident_end":9331,"extent_start":9309,"extent_end":9370,"fully_qualified_name":"evsig_restore_handler_","ident_utf16":{"start":{"line_number":323,"utf16_col":0},"end":{"line_number":323,"utf16_col":22}},"extent_utf16":{"start":{"line_number":323,"utf16_col":0},"end":{"line_number":323,"utf16_col":61}}},{"name":"evsig_del","kind":"function","ident_start":9953,"ident_end":9962,"extent_start":9953,"extent_end":10047,"fully_qualified_name":"evsig_del","ident_utf16":{"start":{"line_number":360,"utf16_col":0},"end":{"line_number":360,"utf16_col":9}},"extent_utf16":{"start":{"line_number":360,"utf16_col":0},"end":{"line_number":360,"utf16_col":94}}},{"name":"evsig_handler","kind":"function","ident_start":10383,"ident_end":10396,"extent_start":10383,"extent_end":10405,"fully_qualified_name":"evsig_handler","ident_utf16":{"start":{"line_number":376,"utf16_col":0},"end":{"line_number":376,"utf16_col":13}},"extent_utf16":{"start":{"line_number":376,"utf16_col":0},"end":{"line_number":376,"utf16_col":22}}},{"name":"evsig_dealloc_","kind":"function","ident_start":11046,"ident_end":11060,"extent_start":11046,"extent_end":11085,"fully_qualified_name":"evsig_dealloc_","ident_utf16":{"start":{"line_number":412,"utf16_col":0},"end":{"line_number":412,"utf16_col":14}},"extent_utf16":{"start":{"line_number":412,"utf16_col":0},"end":{"line_number":412,"utf16_col":39}}},{"name":"evsig_free_globals_locks","kind":"function","ident_start":12090,"ident_end":12114,"extent_start":12090,"extent_end":12120,"fully_qualified_name":"evsig_free_globals_locks","ident_utf16":{"start":{"line_number":453,"utf16_col":0},"end":{"line_number":453,"utf16_col":24}},"extent_utf16":{"start":{"line_number":453,"utf16_col":0},"end":{"line_number":453,"utf16_col":30}}},{"name":"evsig_free_globals_","kind":"function","ident_start":12288,"ident_end":12307,"extent_start":12288,"extent_end":12313,"fully_qualified_name":"evsig_free_globals_","ident_utf16":{"start":{"line_number":465,"utf16_col":0},"end":{"line_number":465,"utf16_col":19}},"extent_utf16":{"start":{"line_number":465,"utf16_col":0},"end":{"line_number":465,"utf16_col":25}}},{"name":"evsig_global_setup_locks_","kind":"function","ident_start":12390,"ident_end":12415,"extent_start":12390,"extent_end":12439,"fully_qualified_name":"evsig_global_setup_locks_","ident_utf16":{"start":{"line_number":472,"utf16_col":0},"end":{"line_number":472,"utf16_col":25}},"extent_utf16":{"start":{"line_number":472,"utf16_col":0},"end":{"line_number":472,"utf16_col":49}}}]}},"copilotInfo":null,"copilotAccessAllowed":false,"modelsAccessAllowed":false,"modelsRepoIntegrationEnabled":false,"csrf_tokens":{"/TitanJP/libevent/branches":{"post":"NUDWSJ868wSxxWjmFOsGHXjtH3O_id0EwwPbTor8mgPKYrjAv5lrYMCaRou73NE7nZ2J3h2gyDq94zSNT_pwdA"},"/repos/preferences":{"post":"ypovmW34FLL4yMzlOFVWxSZYaPd0tv0o9GSngm3S5DsHjejgyyCQ43z2B43W27xaMrhrDPqOEf4zOzi67jZoPQ"}}},"title":"libevent/signal.c at master · TitanJP/libevent","appPayload":{"helpUrl":"https://docs.github.com","findFileWorkerPath":"/assets-cdn/worker/find-file-worker-263cab1760dd.js","findInFileWorkerPath":"/assets-cdn/worker/find-in-file-worker-1b17b3e7786a.js","githubDevUrl":null,"enabled_features":{"code_nav_ui_events":false,"react_blob_overlay":false,"accessible_code_button":true}}}
0