Belle II Software  release-08-01-10
CaptureStreamAbortHandler Class Reference

Small class to handle std::abort() calls by external libraries. More...

Collaboration diagram for CaptureStreamAbortHandler:

Public Member Functions

 CaptureStreamAbortHandler (const CaptureStreamAbortHandler &)=delete
 Singleton, no copy construction.
 
 CaptureStreamAbortHandler (CaptureStreamAbortHandler &&)=delete
 Singleton, no move construction.
 
CaptureStreamAbortHandleroperator= (const CaptureStreamAbortHandler &)=delete
 Singleton, no assignment.
 
void addObject (CaptureStream *obj)
 Add a CaptureStream object to guard against SIGABRT.
 
void removeObject (CaptureStream *obj)
 Remove a CaptureStream object to no longer guard against SIGABRT.
 

Static Public Member Functions

static CaptureStreamAbortHandlergetInstance ()
 Return the singleton instance.
 

Private Member Functions

 CaptureStreamAbortHandler ()
 Register handler.
 

Static Private Member Functions

static void handle (int signal)
 signal handler: print all pending redirection buffers and exit
 

Private Attributes

std::set< CaptureStream * > m_objects
 list of all active stream redirections
 

Detailed Description

Small class to handle std::abort() calls by external libraries.

External libraries like EvtGen seem to prefer calling abort() on error which means destructors are not called and so interception is never finished and thus the error message are lost.

This class installs a SIGABRT handler which is the only way to do something once std::abort() is called and dump all the output intercepted so far back on the original output (stdout or stderr) to basically "reverse" the redirection.

This seems like the best choice since calling abort means the user needs to be able to see the messages

Definition at line 34 of file IOIntercept.cc.


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