2023-02-08 13:17:09 +01:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2004-01-19 22:23:37 +01:00
|
|
|
/*
|
|
|
|
* Quagga Signal handling header.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2004 Paul Jakma.
|
|
|
|
*/
|
|
|
|
|
2021-11-11 20:28:54 +01:00
|
|
|
#ifndef _FRR_SIGNAL_H
|
|
|
|
#define _FRR_SIGNAL_H
|
2004-07-22 21:14:27 +02:00
|
|
|
|
2023-03-07 20:22:48 +01:00
|
|
|
#include <frrevent.h>
|
2004-01-19 22:23:37 +01:00
|
|
|
|
2019-02-07 23:10:31 +01:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2021-11-11 20:28:54 +01:00
|
|
|
#define FRR_SIGNAL_TIMER_INTERVAL 2L
|
2004-01-19 22:23:37 +01:00
|
|
|
|
2021-11-11 20:28:54 +01:00
|
|
|
struct frr_signal_t {
|
2004-01-19 22:23:37 +01:00
|
|
|
int signal; /* signal number */
|
|
|
|
void (*handler)(void); /* handler to call */
|
|
|
|
|
|
|
|
volatile sig_atomic_t caught; /* private member */
|
|
|
|
};
|
|
|
|
|
|
|
|
/* initialise sigevent system
|
|
|
|
* takes:
|
2023-03-07 20:14:41 +01:00
|
|
|
* - pointer to valid struct event_loop
|
2004-01-19 22:23:37 +01:00
|
|
|
* - number of elements in passed in signals array
|
2021-11-11 20:28:54 +01:00
|
|
|
* - array of frr_signal_t's describing signals to handle
|
2004-01-19 22:23:37 +01:00
|
|
|
* and handlers to use for each signal
|
|
|
|
*/
|
2023-03-07 20:14:41 +01:00
|
|
|
extern void signal_init(struct event_loop *m, int sigc,
|
2021-11-11 20:28:54 +01:00
|
|
|
struct frr_signal_t *signals);
|
2004-01-19 22:23:37 +01:00
|
|
|
|
2020-09-02 22:25:00 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Check whether any signals have been received and are pending. This is done
|
|
|
|
* with the application's key signals blocked. The complete set of signals
|
|
|
|
* is returned in 'setp', so the caller can restore them when appropriate.
|
|
|
|
* If there are pending signals, returns 'true', 'false' otherwise.
|
|
|
|
*/
|
|
|
|
bool frr_sigevent_check(sigset_t *setp);
|
|
|
|
|
2004-07-22 21:14:27 +02:00
|
|
|
/* check whether there are signals to handle, process any found */
|
2021-11-11 20:28:54 +01:00
|
|
|
extern int frr_sigevent_process(void);
|
2004-07-22 21:14:27 +02:00
|
|
|
|
2025-02-07 13:22:25 +01:00
|
|
|
/* Ensure we don't handle "application-type" signals on a secondary thread by
|
|
|
|
* blocking these signals when creating threads
|
|
|
|
*
|
|
|
|
* NB: SIGSEGV, SIGABRT, etc. must be allowed on all threads or we get no
|
|
|
|
* crashlogs. Since signals vary a little bit between platforms, below is a
|
|
|
|
* list of known things to go to the main thread. Any unknown signals should
|
|
|
|
* stay thread-local.
|
|
|
|
*/
|
|
|
|
static inline void frr_sigset_add_mainonly(sigset_t *blocksigs)
|
|
|
|
{
|
|
|
|
/* signals we actively handle */
|
|
|
|
sigaddset(blocksigs, SIGHUP);
|
|
|
|
sigaddset(blocksigs, SIGINT);
|
|
|
|
sigaddset(blocksigs, SIGTERM);
|
|
|
|
sigaddset(blocksigs, SIGUSR1);
|
|
|
|
|
|
|
|
/* signals we don't actively use but that semantically belong */
|
|
|
|
sigaddset(blocksigs, SIGUSR2);
|
|
|
|
sigaddset(blocksigs, SIGQUIT);
|
|
|
|
sigaddset(blocksigs, SIGCHLD);
|
|
|
|
sigaddset(blocksigs, SIGPIPE);
|
|
|
|
sigaddset(blocksigs, SIGTSTP);
|
|
|
|
sigaddset(blocksigs, SIGTTIN);
|
|
|
|
sigaddset(blocksigs, SIGTTOU);
|
|
|
|
sigaddset(blocksigs, SIGWINCH);
|
|
|
|
}
|
|
|
|
|
2019-02-07 23:10:31 +01:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2021-11-11 20:28:54 +01:00
|
|
|
#endif /* _FRR_SIGNAL_H */
|