55 { SIGTERM, 4,
"SIGTERM",
"sigterm" },
56 { SIGHUP, 3,
"SIGHUP",
"sighup" },
57 { SIGUSR1, 2,
"SIGUSR1",
"sigusr1" },
58 { SIGUSR2, 1,
"SIGUSR2",
"sigusr2" } };
128 sigprocmask(SIG_BLOCK, &all, NULL);
141 sigprocmask(SIG_SETMASK, &none, NULL);
238 if (signal_text && strcmp(signal_text,
"connection-failed") == 0)
273 if (!signum || sig_saved == signum)
295 const char *t = (title ? title :
"process");
296 const char *hs = NULL;
308 hs =
"connection failed(soft)";
319 msg(msglevel,
"%s[%s,%s] received, %s exiting",
325 msg(msglevel,
"%s[%s,%s] received, %s restarting",
337 msg(msglevel,
"Unknown signal received");
347#ifdef ENABLE_MANAGEMENT
369 NULL, NULL, NULL, NULL);
378signal_handler(
const int signum)
388#define SM_POST_INIT 2
399 sigfillset(&block_mask);
400 sa.sa_handler = signal_handler;
401 sa.sa_mask = block_mask;
402 sa.sa_flags = SA_RESTART;
405 sigaction(SIGINT, &sa, NULL);
406 sigaction(SIGTERM, &sa, NULL);
408 sa.sa_handler = SIG_IGN;
409 sigaction(SIGHUP, &sa, NULL);
410 sigaction(SIGUSR1, &sa, NULL);
411 sigaction(SIGUSR2, &sa, NULL);
412 sigaction(SIGPIPE, &sa, NULL);
428 sigfillset(&block_mask);
429 sa.sa_handler = signal_handler;
430 sa.sa_mask = block_mask;
431 sa.sa_flags = SA_RESTART;
434 sigaction(SIGINT, &sa, NULL);
435 sigaction(SIGTERM, &sa, NULL);
436 sigaction(SIGHUP, &sa, NULL);
437 sigaction(SIGUSR1, &sa, NULL);
438 sigaction(SIGUSR2, &sa, NULL);
439 sa.sa_handler = SIG_IGN;
440 sigaction(SIGPIPE, &sa, NULL);
450 sa.sa_handler = SIG_IGN;
451 sigaction(SIGHUP, &sa, NULL);
452 sigaction(SIGUSR1, &sa, NULL);
453 sigaction(SIGUSR2, &sa, NULL);
502 if (c->
c2.comp_context)
504 comp_print_stats(c->
c2.comp_context, so);
507#ifdef PACKET_TRUNCATION_CHECK
519 status_printf(so,
"TAP-WIN32 driver status,\"%s\"", extended_msg);
536 msg(
M_INFO,
"SIGTERM received, sending exit notification to peer");
629 msg(
M_INFO,
"Converting soft %s received during exit notification to SIGTERM",
static void gc_free(struct gc_arena *a)
static struct gc_arena gc_new(void)
static int dco_get_peer_stats(struct context *c, const bool raise_sigusr1_on_err)
bool send_control_channel_string(struct context *c, const char *str, int msglevel)
void reset_coarse_timers(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.
static bool event_timeout_defined(const struct event_timeout *et)
static void event_timeout_init(struct event_timeout *et, interval_t n, const time_t last)
Initialises a timer struct.
static void event_timeout_clear(struct event_timeout *et)
Clears the timeout and reset all values to 0.
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)
#define OPENVPN_STATE_RECONNECTING
#define OPENVPN_STATE_EXITING
static bool cc_exit_notify_enabled(struct context *c)
Small helper function to determine if we should send the exit notification via control channel.
static bool dco_enabled(const struct options *o)
Returns whether the current configuration has dco enabled.
const char * time_string(time_t t, long usec, bool show_usec, struct gc_arena *gc)
bool process_signal(struct context *c)
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...
static void unblock_async_signals(void)
Unblock all unix signals.
void signal_restart_status(const struct signal_info *si)
void post_init_signal_catch(void)
void throw_signal_soft(const int signum, const char *signal_text)
Throw a soft global signal.
void print_status(struct context *c, struct status_output *so)
const char * signal_name(const int sig, const bool upper)
static bool process_sigterm(struct context *c)
int signal_reset(struct signal_info *si, int signum)
Clear the signal if its current value equals signum.
void process_explicit_exit_notification_timer_wakeup(struct context *c)
static unsigned long long ignored_hard_signals_mask
void pre_init_signal_catch(void)
void remap_signal(struct context *c)
const char * signal_description(const int signum, const char *sigtext)
void restore_signal_state(void)
void throw_signal(const int signum)
Throw a hard signal.
static const struct signame signames[]
int parse_signal(const char *signame)
struct signal_info siginfo_static
void halt_low_priority_signals(void)
static void block_async_signals(void)
Block (i.e., defer) all unix signals.
static void process_explicit_exit_notification_init(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 print_signal(const struct signal_info *si, const char *title, int msglevel)
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.
static int signal_priority(int sig)
static void process_sigusr2(struct context *c)
static void halt_non_edge_triggered_signals(void)
#define SIG_SOURCE_CONNECTION_FAILED
void status_printf(struct status_output *so, const char *format,...)
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 status_flush(struct status_output *so)
void status_reset(struct status_output *so)
bool status_close(struct status_output *so)
int explicit_exit_notification
struct tuntap * tuntap
Tun/tap virtual network interface.
counter_type link_read_bytes
counter_type link_write_bytes
counter_type dco_read_bytes
counter_type tun_read_bytes
counter_type dco_write_bytes
counter_type tun_write_bytes
counter_type link_read_bytes_auth
struct timeval timeval
Time to next event of timers and similar.
time_t explicit_exit_notification_time_wait
struct event_timeout explicit_exit_notification_interval
Contains all state information for one tunnel.
struct signal_info * sig
Internal error signaling object.
struct context_2 c2
Level 2 context.
struct options options
Options loaded from command line or configuration file.
struct context_1 c1
Level 1 context.
Garbage collection arena used to keep track of dynamically allocated memory.
struct connection_entry ce
volatile int signal_received
const char * tap_win_getinfo(const struct tuntap *tt, struct gc_arena *gc)
static bool tuntap_defined(const struct tuntap *tt)