OpenVPN
Data Structures | Macros | Functions | Variables
sig.h File Reference
#include "status.h"
#include "win32.h"
Include dependency graph for sig.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  signal_info
 

Macros

#define SIG_SOURCE_SOFT   0
 
#define SIG_SOURCE_HARD   1
 
#define SIG_SOURCE_CONNECTION_FAILED   2
 
#define IS_SIG(c)   ((c)->sig->signal_received)
 

Functions

int parse_signal (const char *signame)
 
const char * signal_name (const int sig, const bool upper)
 
const char * signal_description (const int signum, const char *sigtext)
 
void throw_signal (const int signum)
 Throw a hard signal. More...
 
void throw_signal_soft (const int signum, const char *signal_text)
 Throw a soft global signal. More...
 
void pre_init_signal_catch (void)
 
void post_init_signal_catch (void)
 
void restore_signal_state (void)
 
void print_signal (const struct signal_info *si, const char *title, int msglevel)
 
void print_status (struct context *c, struct status_output *so)
 
void remap_signal (struct context *c)
 
void signal_restart_status (const struct signal_info *si)
 
bool process_signal (struct context *c)
 
void register_signal (struct signal_info *si, int sig, const char *text)
 Register a soft signal in the signal_info struct si respecting priority. More...
 
void process_explicit_exit_notification_timer_wakeup (struct context *c)
 
int signal_reset (struct signal_info *si, int signum)
 Clear the signal if its current value equals signum. More...
 
static void halt_non_edge_triggered_signals (void)
 
static void get_signal (volatile int *sig)
 Copy the global signal_received (if non-zero) to the passed-in argument sig. More...
 

Variables

struct signal_info siginfo_static
 

Macro Definition Documentation

◆ IS_SIG

#define IS_SIG (   c)    ((c)->sig->signal_received)

Definition at line 48 of file sig.h.

◆ SIG_SOURCE_CONNECTION_FAILED

#define SIG_SOURCE_CONNECTION_FAILED   2

Definition at line 35 of file sig.h.

◆ SIG_SOURCE_HARD

#define SIG_SOURCE_HARD   1

Definition at line 31 of file sig.h.

◆ SIG_SOURCE_SOFT

#define SIG_SOURCE_SOFT   0

Definition at line 30 of file sig.h.

Function Documentation

◆ get_signal()

static void get_signal ( volatile int *  sig)
inlinestatic

Copy the global signal_received (if non-zero) to the passed-in argument sig.

As the former is volatile, do not assign if sig and &signal_received are the same. Even on windows signal_received is really volatile as it can change if a ctrl-C or ctrl-break is delivered. So use the same logic as above.

Also, on windows always call win32_signal_get to pickup any signals simulated by key-board short cuts or the exit event.

Definition at line 110 of file sig.h.

References siginfo_static, signal_info::signal_received, and win32_signal_get().

Referenced by dco_connect_wait(), io_wait_dowork(), man_check_for_signals(), multi_tcp_process_io(), openvpn_connect(), openvpn_getaddrinfo(), recv_line(), recv_socks_reply(), socket_connect(), socket_listen_accept(), socks_handshake(), and socks_username_password_auth().

◆ halt_non_edge_triggered_signals()

static void halt_non_edge_triggered_signals ( void  )
inlinestatic

Definition at line 92 of file sig.h.

References win32_signal_close().

Referenced by process_explicit_exit_notification_init().

◆ parse_signal()

int parse_signal ( const char *  signame)

Definition at line 66 of file sig.c.

References signames, SIZE, signame::upper, and signame::value.

Referenced by man_signal().

◆ post_init_signal_catch()

void post_init_signal_catch ( void  )

Definition at line 427 of file sig.c.

References CLEAR, signal_mode, and SM_POST_INIT.

Referenced by init_instance_handle_signals(), and restore_signal_state().

◆ pre_init_signal_catch()

void pre_init_signal_catch ( void  )

◆ print_signal()

void print_signal ( const struct signal_info si,
const char *  title,
int  msglevel 
)

◆ print_status()

void print_status ( struct context c,
struct status_output so 
)

◆ process_explicit_exit_notification_timer_wakeup()

void process_explicit_exit_notification_timer_wakeup ( struct context c)

◆ process_signal()

bool process_signal ( struct context c)

◆ register_signal()

void register_signal ( struct signal_info si,
int  signum,
const char *  signal_text 
)

◆ remap_signal()

void remap_signal ( struct context c)

◆ restore_signal_state()

void restore_signal_state ( void  )

◆ signal_description()

const char* signal_description ( const int  signum,
const char *  sigtext 
)

Definition at line 107 of file sig.c.

References signal_name().

Referenced by do_close_tun().

◆ signal_name()

const char* signal_name ( const int  sig,
const bool  upper 
)

◆ signal_reset()

int signal_reset ( struct signal_info si,
int  signum 
)

Clear the signal if its current value equals signum.

If signum is zero the signal is cleared independent of its current value.

Returns
the current value of the signal.

If signum is zero the signal is cleared independent of its current value. Returns the current value of the signal.

Definition at line 266 of file sig.c.

References block_async_signals(), D_SIGNAL_DEBUG, msg, SIG_SOURCE_SOFT, siginfo_static, signal_name(), signal_info::signal_received, signal_info::signal_text, signal_info::source, and unblock_async_signals().

Referenced by link_socket_init_phase2(), multi_process_signal(), multi_push_restart_schedule_exit(), openvpn_getaddrinfo(), openvpn_main(), pre_init_signal_catch(), process_explicit_exit_notification_init(), and process_sigusr2().

◆ signal_restart_status()

void signal_restart_status ( const struct signal_info si)

◆ throw_signal()

void throw_signal ( const int  signum)

Throw a hard signal.

Called from management and when windows signals are received through ctrl-c, exit event etc.

Definition at line 177 of file sig.c.

References ASSERT, block_async_signals(), D_SIGNAL_DEBUG, ignored_hard_signals_mask, msg, SIG_SOURCE_HARD, siginfo_static, signal_name(), signal_info::signal_received, try_throw_signal(), and unblock_async_signals().

Referenced by link_socket_init_phase2(), man_connect(), man_signal(), multi_process_timeout(), win32_signal_get(), and win_ctrl_handler().

◆ throw_signal_soft()

void throw_signal_soft ( const int  signum,
const char *  signal_text 
)

Throw a soft global signal.

Used to register internally generated signals due to errors that require a restart or exit, or restart requests received from the server. A textual description of the signal may be provided.

Definition at line 206 of file sig.c.

References block_async_signals(), D_SIGNAL_DEBUG, msg, SIG_SOURCE_SOFT, siginfo_static, signal_name(), signal_info::signal_received, signal_info::signal_text, try_throw_signal(), and unblock_async_signals().

Referenced by apply_pull_filter(), do_preresolve(), man_connect(), and man_reset_client_socket().

Variable Documentation

◆ siginfo_static

struct signal_info siginfo_static