Skip to content

Commit adb4021

Browse files
committedMay 3, 2013
catch system signals and stack trace on linux
1 parent e0907b0 commit adb4021

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed
 

‎src/app/main.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ typedef SInt32 SRefCon;
8181
#if defined(linux) && !defined(ANDROID)
8282
#include <unistd.h>
8383
#include <execinfo.h>
84+
#include <signal.h>
8485
#endif
8586

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

197+
#ifdef Q_OS_UNIX
198+
void qgisCrash( int signal )
199+
{
200+
qFatal( "QGIS died on signal %d", signal );
201+
}
202+
#endif
203+
196204
/*
197205
* Hook into the qWarning/qFatal mechanism so that we can channel messages
198206
* from libpng to the user.
@@ -270,6 +278,16 @@ int main( int argc, char *argv[] )
270278
#if !defined(ANDROID) && !defined(_MSC_VER)
271279
// Set up the custom qWarning/qDebug custom handler
272280
qInstallMsgHandler( myMessageOutput );
281+
282+
signal( SIGQUIT, qgisCrash );
283+
signal( SIGILL, qgisCrash );
284+
signal( SIGFPE, qgisCrash );
285+
signal( SIGSEGV, qgisCrash );
286+
signal( SIGBUS, qgisCrash );
287+
signal( SIGSYS, qgisCrash );
288+
signal( SIGTRAP, qgisCrash );
289+
signal( SIGXCPU, qgisCrash );
290+
signal( SIGXFSZ, qgisCrash );
273291
#endif
274292

275293
#ifdef Q_OS_WIN

0 commit comments

Comments
 (0)
Please sign in to comment.