mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Add option to Preferences to flush file loggers when a signal is triggered
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
|
||||
#include "RiaArgumentParser.h"
|
||||
#include "RiaMainTools.h"
|
||||
#include "RiaPreferences.h"
|
||||
|
||||
#ifdef ENABLE_GRPC
|
||||
#include "RiaGrpcConsoleApplication.h"
|
||||
@@ -39,6 +40,10 @@
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include <signal.h>
|
||||
|
||||
void manageSegFailure( int signalCode );
|
||||
|
||||
RiaApplication* createApplication( int& argc, char* argv[] )
|
||||
{
|
||||
for ( int i = 1; i < argc; ++i )
|
||||
@@ -109,6 +114,17 @@ int main( int argc, char* argv[] )
|
||||
QLocale::setDefault( QLocale( QLocale::English, QLocale::UnitedStates ) );
|
||||
setlocale( LC_NUMERIC, "C" );
|
||||
|
||||
// Set up signal handlers
|
||||
if ( RiaPreferences::current()->loggerTrapSignalAndFlush() )
|
||||
{
|
||||
signal( SIGINT, manageSegFailure );
|
||||
signal( SIGILL, manageSegFailure );
|
||||
signal( SIGFPE, manageSegFailure );
|
||||
signal( SIGSEGV, manageSegFailure );
|
||||
signal( SIGTERM, manageSegFailure );
|
||||
signal( SIGABRT, manageSegFailure );
|
||||
}
|
||||
|
||||
// Handle the command line arguments.
|
||||
// Todo: Move to a one-shot timer, delaying the execution until we are inside the event loop.
|
||||
// The complete handling of the resulting ApplicationStatus must be moved along.
|
||||
|
||||
Reference in New Issue
Block a user