OpenRadioss 2025.1.11
OpenRadioss project
Loading...
Searching...
No Matches
python_signal.h File Reference
#include <csignal>
#include <functional>
#include <iostream>

Go to the source code of this file.

Typedefs

using SignalHandler = std::function<void(int)>

Functions

void signal_dispatcher (int signum)
void activate_signal_handling (SignalHandler handler, int signal=SIGINT)
void restore_default_signal_handling (int signal=SIGINT)

Variables

static SignalHandlercustom_handler_ptr = nullptr

Typedef Documentation

◆ SignalHandler

using SignalHandler = std::function<void(int)>

Definition at line 28 of file python_signal.h.

Function Documentation

◆ activate_signal_handling()

void activate_signal_handling ( SignalHandler handler,
int signal = SIGINT )

Definition at line 41 of file python_signal.h.

41 {
42 static SignalHandler custom_handler; // Keep the handler alive
43 custom_handler = std::move(handler);
44 custom_handler_ptr = &custom_handler;
45 std::signal(signal, signal_dispatcher);
46}
static SignalHandler * custom_handler_ptr
std::function< void(int)> SignalHandler
void signal_dispatcher(int signum)

◆ restore_default_signal_handling()

void restore_default_signal_handling ( int signal = SIGINT)

Definition at line 49 of file python_signal.h.

49 {
50 std::signal(signal, SIG_DFL);
51}

◆ signal_dispatcher()

void signal_dispatcher ( int signum)

Definition at line 34 of file python_signal.h.

34 {
36 (*custom_handler_ptr)(signum);
37 }
38}

Variable Documentation

◆ custom_handler_ptr

SignalHandler* custom_handler_ptr = nullptr
static

Definition at line 31 of file python_signal.h.