VideoTools
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
G::Cleanup Class Reference

A static interface for registering cleanup functions that are called when the process terminates abnormally. More...

#include <gcleanup.h>

Static Public Member Functions

static void init ()
 An optional early-initialisation function. May be called more than once.
 
static void add (void(*fn)(SignalSafe, const char *), const char *arg)
 Adds the given handler to the list of handlers that are to be called when the process terminates abnormally. More...
 
static void atexit (bool active=true)
 Ensures that the cleanup functions are also called via atexit(), in addition to abnormal-termination signals. More...
 

Detailed Description

A static interface for registering cleanup functions that are called when the process terminates abnormally.

On unix this relates to signals like SIGTERM, SIGINT etc.

Definition at line 39 of file gcleanup.h.

Member Function Documentation

void G::Cleanup::add ( void(*)(SignalSafe, const char *)  fn,
const char *  arg 
)
static

Adds the given handler to the list of handlers that are to be called when the process terminates abnormally.

The handler function must be fully reentrant, hence the SignalSafe dummy parameter. The 'arg' pointer is kept.

Definition at line 103 of file gcleanup_unix.cpp.

void G::Cleanup::atexit ( bool  active = true)
static

Ensures that the cleanup functions are also called via atexit(), in addition to abnormal-termination signals.

This can be useful when third-party library code (eg. Xlib) might call exit() (grrr). But be careful to call atexit(false) before normal termination, returning from main().

Definition at line 108 of file gcleanup_unix.cpp.


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