holoscan::SignalHandler

Beta
View as Markdown

The SignalHandler class provides a mechanism to handle signals in a C++ program.

The SignalHandler class provides a way to handle signals in a C++ program. It allows registering global signal handlers and context-specific signal handlers. The class is implemented as a singleton, and its instance can be obtained using the get_instance() method.

#include <holoscan/signal_handler.hpp>

Constructors

SignalHandler

Constructs a SignalHandler object.

Destructor

~SignalHandler

Destructs a SignalHandler object.


Methods

install_signal_handler_impl

void holoscan::SignalHandler::install_signal_handler_impl(
int signal = 0
)

register_global_signal_handler_impl

void holoscan::SignalHandler::register_global_signal_handler_impl(
int signal,
std::function<void(int)> handler,
bool overwrite = false
)

register_signal_handler_impl

void holoscan::SignalHandler::register_signal_handler_impl(
void *context,
int signal,
std::function<void(void *, int)> handler,
bool overwrite = false
)

unregister_global_signal_handler_impl

void holoscan::SignalHandler::unregister_global_signal_handler_impl(
int signal
)

unregister_signal_handler_impl

void holoscan::SignalHandler::unregister_signal_handler_impl(
void *context,
int signal
)

handle_signal

void holoscan::SignalHandler::handle_signal(
int signal
)

Static methods

get_instance

static SignalHandler & holoscan::SignalHandler::get_instance()

Returns the singleton instance of the SignalHandler class.

Returns: SignalHandler& The singleton instance of the SignalHandler class.

static_handle_signal

static void holoscan::SignalHandler::static_handle_signal(
int signal
)

The static method to handles the specified signal.

Parameters

signal
int

The signal to handle.

install_signal_handler

static void holoscan::SignalHandler::install_signal_handler(
int signal = 0
)

Installs the signal handler for the specified signal.

Parameters

signal
intDefaults to 0

The signal to install the signal handler for. If signal is 0, the signal handler is installed for all existing signals.

register_global_signal_handler

static void holoscan::SignalHandler::register_global_signal_handler(
int signal,
std::function<void(int)> handler,
bool overwrite = false
)

Registers a global signal handler for the specified signal.

Parameters

signal
int

The signal to register the global signal handler for.

handler
std::function<void(int)>

The global signal handler function.

overwrite
boolDefaults to false

If true, overwrites any existing global signal handler for the specified signal.

register_signal_handler

static void holoscan::SignalHandler::register_signal_handler(
void *context,
int signal,
std::function<void(void *, int)> handler,
bool overwrite = false
)

Registers a context-specific signal handler for the specified signal.

Parameters

context
void *

The context to register the signal handler for.

signal
int

The signal to register the signal handler for.

handler
std::function<void(void *, int)>

The signal handler function.

overwrite
boolDefaults to false

If true, overwrites any existing signal handler for the specified context and signal.

unregister_global_signal_handler

static void holoscan::SignalHandler::unregister_global_signal_handler(
int signal
)

Unregisters the global signal handler for the specified signal.

Parameters

signal
int

The signal to unregister the global signal handler for.

unregister_signal_handler

static void holoscan::SignalHandler::unregister_signal_handler(
void *context,
int signal
)

Unregisters the context-specific signal handler for the specified context and signal.

Parameters

context
void *

The context to unregister the signal handler for.

signal
int

The signal to unregister the signal handler for.

clear_all_signal_handlers

static void holoscan::SignalHandler::clear_all_signal_handlers()

Clears all signal handlers.

clear_global_signal_handlers

static void holoscan::SignalHandler::clear_global_signal_handlers()

Clears all global signal handlers.

clear_signal_handlers

static void holoscan::SignalHandler::clear_signal_handlers()

Clears all context-specific signal handlers.


Types

Typedefs

NameDefinitionDescription
GlobalSignalHandlerMapstd::unordered_map< int, std::function< void(int)> >Type definition for a global signal handler map.
SignalHandlerMapstd::unordered_map< int, std::function< void(void *, int)> >Type definition for a signal handler map.
ContextSignalHandlerMapstd::unordered_map< void *, SignalHandlerMap >Type definition for a context-specific signal handler map.

Member variables

NameTypeDescription
global_signal_handlers_GlobalSignalHandlerMapThe global signal handler map.
signal_handlers_ContextSignalHandlerMapThe context-specific signal handler map.
signal_handlers_mutex_std::recursive_mutexThe mutex to protect the signal handler maps.
old_signal_handlers_std::unordered_map< int, struct sigaction >The old signal handler map.
signal_handler_ staticstruct sigactionThe signal handler struct.