Go to the documentation of this file.
55 { SIGINT, 5,
"SIGINT",
"sigint"},
56 { SIGTERM, 4,
"SIGTERM",
"sigterm" },
57 { SIGHUP, 3,
"SIGHUP",
"sighup" },
58 { SIGUSR1, 2,
"SIGUSR1",
"sigusr1" },
59 { SIGUSR2, 1,
"SIGUSR2",
"sigusr2" }
130 sigprocmask(SIG_BLOCK, &all, NULL);
143 sigprocmask(SIG_SETMASK, &none, NULL);
241 if (signal_text && strcmp(signal_text,
"connection-failed") == 0)
277 if (!signum || sig_saved == signum)
299 const char *t = (title ? title :
"process");
300 const char *hs = NULL;
312 hs =
"connection failed(soft)";
323 msg(msglevel,
"%s[%s,%s] received, %s exiting",
329 msg(msglevel,
"%s[%s,%s] received, %s restarting",
334 msg(msglevel,
"Unknown signal %d [%s,%s] received by %s", si->
signal_received, hs, type, t);
340 msg(msglevel,
"Unknown signal received");
350 #ifdef ENABLE_MANAGEMENT
384 signal_handler(
const int signum)
393 #define SM_PRE_INIT 1
394 #define SM_POST_INIT 2
405 sigfillset(&block_mask);
406 sa.sa_handler = signal_handler;
407 sa.sa_mask = block_mask;
408 sa.sa_flags = SA_RESTART;
411 sigaction(SIGINT, &sa, NULL);
412 sigaction(SIGTERM, &sa, NULL);
414 sa.sa_handler = SIG_IGN;
415 sigaction(SIGHUP, &sa, NULL);
416 sigaction(SIGUSR1, &sa, NULL);
417 sigaction(SIGUSR2, &sa, NULL);
418 sigaction(SIGPIPE, &sa, NULL);
434 sigfillset(&block_mask);
435 sa.sa_handler = signal_handler;
436 sa.sa_mask = block_mask;
437 sa.sa_flags = SA_RESTART;
440 sigaction(SIGINT, &sa, NULL);
441 sigaction(SIGTERM, &sa, NULL);
442 sigaction(SIGHUP, &sa, NULL);
443 sigaction(SIGUSR1, &sa, NULL);
444 sigaction(SIGUSR2, &sa, NULL);
445 sa.sa_handler = SIG_IGN;
446 sigaction(SIGPIPE, &sa, NULL);
456 sa.sa_handler = SIG_IGN;
457 sigaction(SIGHUP, &sa, NULL);
458 sigaction(SIGUSR1, &sa, NULL);
459 sigaction(SIGUSR2, &sa, NULL);
503 if (c->
c2.comp_context)
505 comp_print_stats(c->
c2.comp_context, so);
508 #ifdef PACKET_TRUNCATION_CHECK
520 status_printf(so,
"TAP-WIN32 driver status,\"%s\"", extended_msg);
537 msg(
M_INFO,
"SIGTERM received, sending exit notification to peer");
630 msg(
M_INFO,
"Converting soft %s received during exit notification to SIGTERM",
struct status_output * status_open(const char *filename, const int refresh_freq, const int msglevel, const struct virtual_output *vout, const unsigned int flags)
void signal_restart_status(const struct signal_info *si)
void management_set_state(struct management *man, const int state, const char *detail, const in_addr_t *tun_local_ip, const struct in6_addr *tun_local_ip6, const struct openvpn_sockaddr *local, const struct openvpn_sockaddr *remote)
volatile int signal_received
void print_signal(const struct signal_info *si, const char *title, int msglevel)
static struct gc_arena gc_new(void)
int explicit_exit_notification
#define OPENVPN_STATE_EXITING
void restore_signal_state(void)
struct tuntap * tuntap
Tun/tap virtual network interface.
counter_type link_write_bytes
Contains all state information for one tunnel.
static void block_async_signals(void)
Block (i.e., defer) all unix signals.
counter_type tun_read_bytes
void reset_coarse_timers(struct context *c)
struct connection_entry ce
int dco_get_peer_stats(struct context *c)
static void event_timeout_init(struct event_timeout *et, interval_t n, const time_t last)
Initialises a timer struct.
const char * tap_win_getinfo(const struct tuntap *tt, struct gc_arena *gc)
void throw_signal_soft(const int signum, const char *signal_text)
Throw a soft global signal.
counter_type link_read_bytes
struct context_2 c2
Level 2 context.
static bool tuntap_defined(const struct tuntap *tt)
void halt_low_priority_signals(void)
int parse_signal(const char *signame)
void status_reset(struct status_output *so)
void process_explicit_exit_notification_timer_wakeup(struct context *c)
static int signal_priority(int sig)
const char * signal_name(const int sig, const bool upper)
static void process_sigusr2(struct context *c)
#define SIG_SOURCE_CONNECTION_FAILED
counter_type dco_write_bytes
static void halt_non_edge_triggered_signals(void)
struct options options
Options loaded from command line or configuration file.
void status_printf(struct status_output *so, const char *format,...)
void throw_signal(const int signum)
Throw a hard signal.
time_t explicit_exit_notification_time_wait
counter_type tun_write_bytes
void pre_init_signal_catch(void)
bool process_signal(struct context *c)
struct timeval timeval
Time to next event of timers and similar.
int signal_reset(struct signal_info *si, int signum)
Clear the signal if its current value equals signum.
static bool cc_exit_notify_enabled(struct context *c)
Small helper function to determine if we should send the exit notification via control channel.
struct event_timeout explicit_exit_notification_interval
bool status_close(struct status_output *so)
#define OPENVPN_STATE_RECONNECTING
static bool try_throw_signal(struct signal_info *si, int signum, int source)
Private function for registering a signal in the specified signal_info struct.
Garbage collection arena used to keep track of dynamically allocated memory.
struct signal_info * sig
Internal error signaling object.
void status_flush(struct status_output *so)
static bool dco_enabled(const struct options *o)
Returns whether the current configuration has dco enabled.
static unsigned long long ignored_hard_signals_mask
static void process_explicit_exit_notification_init(struct context *c)
bool event_timeout_trigger(struct event_timeout *et, struct timeval *tv, const int et_const_retry)
This is the principal function for testing and triggering recurring timers.
counter_type dco_read_bytes
static void gc_free(struct gc_arena *a)
static void unblock_async_signals(void)
Unblock all unix signals.
const char * time_string(time_t t, int usec, bool show_usec, struct gc_arena *gc)
static void remap_restart_signals(struct context *c)
If a soft restart signal is received during exit-notification, it implies the event loop cannot conti...
counter_type link_read_bytes_auth
void print_status(struct context *c, struct status_output *so)
static bool event_timeout_defined(const struct event_timeout *et)
static const struct signame signames[]
static void event_timeout_clear(struct event_timeout *et)
Clears the timeout and reset all values to 0.
void remap_signal(struct context *c)
void register_signal(struct signal_info *si, int signum, const char *signal_text)
Register a soft signal in the signal_info struct si respecting priority.
void post_init_signal_catch(void)
struct signal_info siginfo_static
static bool process_sigterm(struct context *c)
struct context_1 c1
Level 1 context.
const char * signal_description(const int signum, const char *sigtext)
bool send_control_channel_string(struct context *c, const char *str, int msglevel)