diff options
author | Chris Hall <chris.hall@highwayman.com> | 2011-07-21 19:53:02 +0100 |
---|---|---|
committer | Chris Hall <chris.hall@highwayman.com> | 2011-07-21 19:53:02 +0100 |
commit | 56da2a1c9b6361e302b7a39fe2740561a9012d88 (patch) | |
tree | 6b6543532133a0c618d0f4ec70a87cf3f96caf30 /lib/sigevent.c | |
parent | e535bc959729262480a9702e71334002edee3f8c (diff) | |
download | quagga-56da2a1c9b6361e302b7a39fe2740561a9012d88.tar.bz2 quagga-56da2a1c9b6361e302b7a39fe2740561a9012d88.tar.xz |
Update pipework and improve memory reporting.
Improve error handling for all new pipework inputs and outputs.
Change behaviour of ^C from VTY Terminal, so that will interrupt
output and terminate all running pipes -- including running
shell commands.
In pipe commands, recognise "~/..." and "~user/..." home directory
forms.
Changed "~/" to mean the usual home for the current user. "~~/"
now means the configuration file directory.
Introduced "shdir DIR" command to show what is (currently) what.
Changed "<|" so that if the command has a path, it is expanded
using Quagga's rules (including "~~/" and "~./") and the
"here" directory is set to that path.
Fixed collection of stderr output from all pipes so that is
separate from stdout output, and is always sent to the base
output (eg VTY Terminal).
Increase amount of information about the heap that "show mem"
shows -- particularly if the "memory_tracker" is enabled.
Tested and applied resulting fixes.
Diffstat (limited to 'lib/sigevent.c')
-rw-r--r-- | lib/sigevent.c | 36 |
1 files changed, 26 insertions, 10 deletions
diff --git a/lib/sigevent.c b/lib/sigevent.c index c7c1e134..5dfb67cf 100644 --- a/lib/sigevent.c +++ b/lib/sigevent.c @@ -147,8 +147,8 @@ static sigset_t qsig_interrupts[1] ; static sigset_t qsig_reserved[1] ; static void qsig_add(int signo, qsig_event* event) ; -static int signal_set_set(sigset_t* set, sig_handler* handler) ; -static int signal_set(int signo, sig_handler* handler) ; +static int signal_set_set(sigset_t* set, sig_handler* handler, bool required) ; +static int signal_set(int signo, sig_handler* handler, bool required) ; static void __attribute__ ((noreturn)) core_handler(int signo, siginfo_t *info, void *context) ; @@ -362,11 +362,11 @@ signal_init (struct thread_master *m, int sigc, sigsubsets(core_signals, qsig_interrupts) ; /* Install handlers */ - signal_set_set(core_signals, core_handler) ; - signal_set_set(exit_signals, exit_handler) ; - signal_set_set(ignore_signals, NULL) ; - signal_set_set(qsig_signals, quagga_signal_handler) ; - signal_set_set(qsig_interrupts, quagga_interrupt_handler) ; + signal_set_set(core_signals, core_handler, false) ; + signal_set_set(exit_signals, exit_handler, false) ; + signal_set_set(ignore_signals, NULL, false) ; + signal_set_set(qsig_signals, quagga_signal_handler, true) ; + signal_set_set(qsig_interrupts, quagga_interrupt_handler, true) ; /* If using a timer thread to scan for signal events, start that now. */ @@ -695,7 +695,7 @@ quagga_signal_reset(void) * Returns: < 0 => failed -- value is - failing signo ! */ static int -signal_set_set(sigset_t* set, sig_handler* handler) +signal_set_set(sigset_t* set, sig_handler* handler, bool required) { int signo ; @@ -707,7 +707,7 @@ signal_set_set(sigset_t* set, sig_handler* handler) if (s < 0) break ; if (s > 0) - if (signal_set(signo, handler) < 0) + if (signal_set(signo, handler, required) < 0) return -signo ; } ; @@ -727,10 +727,26 @@ signal_set_set(sigset_t* set, sig_handler* handler) #endif static int -signal_set(int signo, sig_handler* handler) +signal_set(int signo, sig_handler* handler, bool required) { struct sigaction act[1] ; + /* If a signal handler is already set for the given signal then we leave + * that as it is -- unless this is one of the "required" signals, used by + * Quagga. + */ + sigaction(signo, NULL, act) ; + + if ((act->sa_handler != SIG_DFL) && (act->sa_handler != SIG_IGN)) + { + if (!required) + return 0 ; + } ; + + /* Set our handler */ + + memset(act, 0, sizeof(struct sigaction)) ; + if (handler == NULL) { act->sa_handler = SIG_IGN ; |