summaryrefslogtreecommitdiffstats
path: root/lib/sigevent.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* *: remove THREAD_ON macros, add nullity checkQuentin Young2017-05-091-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | The way thread.c is written, a caller who wishes to be able to cancel a thread or avoid scheduling it twice must keep a reference to the thread. Typically this is done with a long lived pointer whose value is checked for null in order to know if the thread is currently scheduled. The check-and-schedule idiom is so common that several wrapper macros in thread.h existed solely to provide it. This patch removes those macros and adds a new parameter to all thread_add_* functions which is a pointer to the struct thread * to store the result of a scheduling call. If the value passed is non-null, the thread will only be scheduled if the value is null. This helps with consistency. A Coccinelle spatch has been used to transform code of the form: if (t == NULL) t = thread_add_* (...) to the form thread_add_* (..., &t) The THREAD_ON macros have also been transformed to the underlying thread.c calls. Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
* lib: make sure SEGV handler cannot lock upDavid Lamparter2017-03-311-0/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Just adding -pthread to gcc options changes libc's behaviour, e.g. making malloc() use proper locking. This means a SEGV inside malloc() (e.g. because malloc bookkeeping structures have been damaged by writing to a broken pointer) can lead to a lockup by the following chain: - random_function() - malloc() --- SEGV - core_handler() - zlog_backtrace_sigsafe() - backtrace() - malloc() This will hang forever waiting for the malloc() lock to be released. Another failure mode is dynamic linking with lazy binding (-z lazy, default). Since backtrace() is seldomly used, this means the call to backtrace() in the core handler can in fact result in the dynamic linker trying to resolve the "backtrace" symbol, which can also deadlock. Add several safeguards to prevent any of this from happening. (Unfortunately, these are not theoretical issues - I found them by running into them headfirst.) Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* ldpd: ignore the SIGHUP signal in the child processesRenato Westphal2017-03-271-1/+2
| | | | | | | | Only the parent process should handle the SIGHUP signal, but we need to make sure that this signal is ignored in the child processes so a command like "killall -SIGHUP ldpd" won't kill ldpd. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
* lib: dump memory stats on coreLou Berger2016-09-031-0/+2
|
* [lib] Add support for backtrace on more platformsJoakim Tjernlund2016-05-261-4/+28
| | | | | | | * lib/sigevent.c: (program_counter) extend to support more platforms. Joint effort with Paul Jakma. (cherry picked from commit b166ea2dda9f04a8b75e0bf5adb7064580695f22)
* *: use array_size() helper macroBalaji.G2012-10-251-4/+5
| | | | | | | | Use the array_size() helper macro. Replaces several instances of local macros with the same definition. Reviewed-by: Scott Feldman <sfeldma@cumulusnetworks.com> Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* 2005-05-06 Paul Jakma <paul@dishone.st>paul2005-05-061-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | * (general) extern and static'ification of functions in code and header. Cleanup any definitions with unspecified arguments. Add casts for callback assignments where the callback is defined, typically, as passing void *, but the function being assigned has some other pointer type defined as its argument, as gcc complains about casts from void * to X* via function arguments. Fix some old K&R style function argument definitions. Add noreturn gcc attribute to some functions, as appropriate. Add unused gcc attribute to some functions (eg ones meant to help while debugging) Add guard defines to headers which were missing them. * command.c: (install_node) add const qualifier, still doesnt shut up the warning though, because of the double pointer. (cmp_node) ditto * keychain.c: (key_str2time) Add GET_LONG_RANGE() macro, derived fromn vty.h ones to fix some of the (long) < 0 warnings. * thread.c: (various) use thread_empty (cpu_record_hash_key) should cast to uintptr_t, a stdint.h type * vty.h: Add VTY_GET_IPV4_ADDRESS and VTY_GET_IPV4_PREFIX so they removed from ospfd/ospf_vty.h * zebra.h: Move definition of ZEBRA_PORT to here, to remove dependence of lib on zebra/zserv.h
* 2005-04-08 Andrew J. Schorr <ajschorr@alumni.princeton.edu>ajs2005-04-081-0/+2
| | | | * sigevent.c: On GNU_LINUX, check whether __USE_GNU is already defined.
* 2005-01-18 Andrew J. Schorr <ajschorr@alumni.princeton.edu>ajs2005-01-181-5/+36
| | | | | | | | | | | | | | | | * log.h: Test for SA_SIGINFO to see whether zlog_signal takes final two args (siginfo and program_counter). * log.c: (hex_append) Include this function only if SA_SIGINFO or HAVE_GLIBC_BACKTRACE is defined. (zlog_signal) Final two args (siginfo and program_counter) now depend on whether SA_SIGINFO is defined on this platform. * sigevent.c: (program_counter) Do not include this function if SA_SIGINFO is not defined on this platform. (exit_handler,core_handler) Test for SA_SIGINFO to decide whether 2nd & 3rd arguments are present and to decide how to invoke zlog_signal. (trap_default_signals) Test for SA_SIGINFO and invoke sigaction appropriately.
* 2005-01-12 Andrew J. Schorr <ajschorr@alumni.princeton.edu>ajs2005-01-121-11/+45
| | | | | | | | | | | | | | | | | | | * configure.ac: Test for header file <ucontext.h> (for use in signal processing). * sigevent.c: (trap_default_signals) Use the SA_SIGINFO flag to pass additional siginfo_t and ucontext_t arguments to core_handler and exit_handler. (core_handler,exit_handler) Now invoked with 3 arguments (using SA_SIGINFO). Pass additional info to zlog_signal. (program_counter) New function to find program counter in ucontext_t, needs to be enhanced to support more platforms (currently works only on Linux/x86). * log.h: Change the zlog_signal prototype to add new arguments siginfo_t * and program_counter. * log.c: (zlog_signal) Add new arguments siginfo and program_counter. Include si_addr and program counter (if non-NULL) in message. And remove #ifdef HAVE_GLIBC_BACKTRACE around hex_append, since that is now used to render the si_addr and PC pointers.
* 2004-12-15 Andrew J. Schorr <ajschorr@alumni.princeton.edu>ajs2004-12-151-6/+9
| | | | * sigevent.c: (trap_default_signals) Ignore SIGPIPE instead of exiting.
* 2004-11-23 Andrew J. Schorr <ajschorr@alumni.princeton.edu>ajs2004-11-231-2/+93
| | | | | | | | | | | | | | | * sigevent.c: (signal_init) Set up some default signal handlers so that processes will issue an error message before terminating or dumping core. (trap_default_signals) New function to set up signal handlers for various signals that may kill the process. (exit_handler) Call zlog_signal, then _exit. (core_handler) Call zlog_signal, then abort. * log.h: Declare new function zlog_signal. * log.c: (zlog_signal) New function to log information about a received signal before the process dies. Try to log a backtrace also. (quagga_signal_handler,signal_set) Should be static.
* 2004-07-14 Paul Jakma <paul@dishone.st>paul2004-07-221-29/+54
| | | | | | | | | | | | | | | | | * sigevent.c: (quagga_signal_handler) add a global caught flag, set the flags to a constant rather increment to be kinder. (quagga_sigevent_process) new function, to do core of what quagga_signal_timer did. dont block signals at all as sig->caught is volatile sig_atomic_t and should be safe to access from signal and normal contexts. The signal blocking is unneeded paranoia, but is left intact under an ifdef, should some platform require it. Check global caught flag before iterating through array. (quagga_signal_timer) nearly everything moved to quagga_sigevent_process. Left in under ifdef, in case some platform could use a regular timer check for signals. * sigevent.h: quagga_sigevent_process declaration. * thread.c: (thread_fetch) check for signals at beginning of scheduler loop, check for signals if select returns EINTR.
* 2004-07-13 Greg Troxel <gdt@poblano.ir.bbn.com>gdt2004-07-131-1/+8
| | | | | | * sigevent.c: Don't block SIGTRAP and SIGKILL. Blocking SIGTRAP confuses gdb, at least on NetBSD 2.0_BETA, where the block succeeds.
* 2004-01-19 Paul Jakma <paul@dishone.st>paul2004-01-191-0/+147
* sigevent.{c,h}: New files, implement event handled signals. see signal_init() in sigevent.h.