Signal Handling


The engine provides rudimentary signal handling that utilises the “self-pipe trick”. Your class can access the signal_handler through signal_handler& engine::get_signal_handler() and use this to register for notification every time a signal is caught.


class zab::signal_handler

This class describes a signal handler for re-entrant signals.

There can only be 1 signal_handler active at 1 time.

Public Types

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

Public Functions

signal_handler(engine *_engine)

initialise the handler with an engine to re-enter into.

Parameters

_engine – The engine.

signal_handler(signal_handler &&_move) = default
~signal_handler()

Destroys the signal_handler and resets the callbacks to default.

async_function run()

run the signal loop.

void stop()

stop the signal loop.

bool handle(int _sig, thread_t _thread, handler &&_function) noexcept

Register a handler for a given signal.

Parameters
  • _sig[in] The signal to handle.

  • _thread[in] The thread to run on.

  • _function – The function to call.

Returns

If registereds successfully.

bool is_active()

Determines if signal_handler this active.

Returns

true if active, false otherwise.

Public Static Attributes

static constexpr thread_t kSignalThread = thread_t{0}