libmoost
moost::process::quit_handler Class Reference

Note, SIGKILL and SIGSTOP are not handled (this is a Posix restriction). More...

#include <quit_handler.hpp>

List of all members.

Public Types

typedef boost::function< void()> handler_t

Static Public Member Functions

static void set (handler_t const &handler, bool trap_abort=true, bool trap_hup=false)

Private Member Functions

void register_handler (bool trap_abort)

Static Private Member Functions

static quit_handlerget_single_instance ()
static void sighandler (int)

Private Attributes

handler_t handler_
struct sigaction sa_

Detailed Description

Note, SIGKILL and SIGSTOP are not handled (this is a Posix restriction).

This class represent and very simple way to trap and handle termination signals. It is not and never was intended to be a fully fledged signal handling framework. It's only job in life is to allow you to register a handler (which can be a simple free standing function or a functor), which will be called if any of the standard (and trapable) signals are raised. The idea is that you use your custom handler to shutdown your process gracefully; allowing you to persist data and stop services.

To use it just call it from an approppriate place in your main thread before you start any services or actions that might need clearing up on termination. It is up to you to ensure your custom handler shuts down your process. The normal action of termination will be disabled.

By default SIGABRT is also handled but you can disable this as required.

By default SIGHUP is not handled. You can add this if required but the preferred method is to use the "hup_handler" and reload the config.

Definition at line 60 of file quit_handler.hpp.


Member Typedef Documentation

typedef boost::function<void ()> moost::process::quit_handler::handler_t

Definition at line 71 of file quit_handler.hpp.


Member Function Documentation

static quit_handler& moost::process::quit_handler::get_single_instance ( ) [inline, static, private]

Definition at line 64 of file quit_handler.hpp.

Here is the caller graph for this function:

void moost::process::quit_handler::register_handler ( bool  trap_abort) [inline, private]

Definition at line 103 of file quit_handler.hpp.

Here is the call graph for this function:

Here is the caller graph for this function:

static void moost::process::quit_handler::set ( handler_t const &  handler,
bool  trap_abort = true,
bool  trap_hup = false 
) [inline, static]

Definition at line 74 of file quit_handler.hpp.

Here is the call graph for this function:

Here is the caller graph for this function:

static void moost::process::quit_handler::sighandler ( int  ) [inline, static, private]

Definition at line 91 of file quit_handler.hpp.

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

struct sigaction moost::process::quit_handler::sa_ [private]

Definition at line 102 of file quit_handler.hpp.


The documentation for this class was generated from the following file: