Skip to content

Commit

Permalink
catch system signals and stack trace on linux
Browse files Browse the repository at this point in the history
  • Loading branch information
jef-n committed May 3, 2013
1 parent e0907b0 commit adb4021
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/app/main.cpp
Expand Up @@ -81,6 +81,7 @@ typedef SInt32 SRefCon;
#if defined(linux) && !defined(ANDROID)
#include <unistd.h>
#include <execinfo.h>
#include <signal.h>
#endif

// (if Windows/Mac, use icon from resource)
Expand Down Expand Up @@ -193,6 +194,13 @@ LONG WINAPI qgisCrashDump( struct _EXCEPTION_POINTERS *ExceptionInfo )
}
#endif

#ifdef Q_OS_UNIX
void qgisCrash( int signal )
{
qFatal( "QGIS died on signal %d", signal );
}
#endif

/*
* Hook into the qWarning/qFatal mechanism so that we can channel messages
* from libpng to the user.
Expand Down Expand Up @@ -270,6 +278,16 @@ int main( int argc, char *argv[] )
#if !defined(ANDROID) && !defined(_MSC_VER)
// Set up the custom qWarning/qDebug custom handler
qInstallMsgHandler( myMessageOutput );

signal( SIGQUIT, qgisCrash );
signal( SIGILL, qgisCrash );
signal( SIGFPE, qgisCrash );
signal( SIGSEGV, qgisCrash );
signal( SIGBUS, qgisCrash );
signal( SIGSYS, qgisCrash );
signal( SIGTRAP, qgisCrash );
signal( SIGXCPU, qgisCrash );
signal( SIGXFSZ, qgisCrash );
#endif

#ifdef Q_OS_WIN
Expand Down

0 comments on commit adb4021

Please sign in to comment.