Created
July 13, 2010 10:34
-
-
Save Gautier/473710 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Index: sources/rtmpserver/src/rtmpserver.cpp | |
=================================================================== | |
--- sources/rtmpserver/src/rtmpserver.cpp (revision 1315) | |
+++ sources/rtmpserver/src/rtmpserver.cpp (working copy) | |
@@ -27,6 +27,8 @@ | |
* POSSIBILITY OF SUCH DAMAGE. | |
*/ | |
+#include <stdlib.h> | |
+#include <execinfo.h> | |
#include "netio/netio.h" | |
#include "configuration/configfile.h" | |
#include "protocols/protocolmanager.h" | |
@@ -63,11 +65,13 @@ | |
RunningStatus gRs = {0}; | |
+void print_trace(int nSig); | |
int main(int argc, char **argv) { | |
//1. Pick up the startup parameters and hold them inside the running status | |
gRs.argc = argc; | |
gRs.argv = argv; | |
+signal(SIGSEGV, print_trace); | |
do { | |
//2. Reset the run flag | |
gRs.run = false; | |
@@ -238,3 +242,22 @@ | |
gRs.run = true; | |
IOHandlerManager::SignalShutdown(); | |
} | |
+ | |
+void print_trace(int nSig) { | |
+ printf("print_trace: got signal %d\n", nSig); | |
+ | |
+ void *array[32]; /* Array to store backtrace symbols */ | |
+ size_t size; /* To store the exact no of values stored */ | |
+ char **strings; /* To store functions from the backtrace list in ARRAY */ | |
+ size_t nCnt; | |
+ | |
+ size = backtrace(array, 32); | |
+ | |
+ strings = backtrace_symbols(array, size); | |
+ | |
+ /* prints each string of function names of trace*/ | |
+ for (nCnt = 0; nCnt < size; nCnt++) | |
+ fprintf(stderr, "%s\n", strings[nCnt]); | |
+ | |
+ exit(-1); | |
+} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment