Belle II Software light-2406-ragdoll
|
Small class to handle std::abort() calls by external libraries. More...
Public Member Functions | |
CaptureStreamAbortHandler (const CaptureStreamAbortHandler &)=delete | |
Singleton, no copy construction. | |
CaptureStreamAbortHandler (CaptureStreamAbortHandler &&)=delete | |
Singleton, no move construction. | |
CaptureStreamAbortHandler & | operator= (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 CaptureStreamAbortHandler & | getInstance () |
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 | |
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.
|
inlineprivate |
Register handler.
Definition at line 54 of file IOIntercept.cc.
|
inline |
Add a CaptureStream object to guard against SIGABRT.
Definition at line 49 of file IOIntercept.cc.
|
inlinestatic |
Return the singleton instance.
Definition at line 43 of file IOIntercept.cc.
|
staticprivate |
signal handler: print all pending redirection buffers and exit
Definition at line 65 of file IOIntercept.cc.
|
inline |
Remove a CaptureStream object to no longer guard against SIGABRT.
Definition at line 51 of file IOIntercept.cc.
|
private |
list of all active stream redirections
Definition at line 62 of file IOIntercept.cc.