Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

a signal handler with SIGSEGV #130

Closed
lxlenovostar opened this issue Apr 16, 2018 · 1 comment
Closed

a signal handler with SIGSEGV #130

lxlenovostar opened this issue Apr 16, 2018 · 1 comment

Comments

@lxlenovostar
Copy link

I want to print call stack, when a SIGSEGV happen.

void handle_signal_handler(int sig) {
 243     DEBUG_INFO("get signal: %d\n", sig);
 244     if (sig == SIGSEGV) {
 245         dump_trace();
 246     }                
 247      
 248     re_cancel();
 249 }   

In main function:
2889 EOR(re_main(handle_signal_handler));

I think handle_signal_handler will be call by signal 2(SIGINT), not signal 11(SIGSEGV).

This is why? Thank you.

@alfredh
Copy link
Contributor

alfredh commented May 11, 2018

printing the call stack should be done with a debugger like gdb or lldb.

if you want to print the call stack in your program, you can try the backtrace function:

http://man7.org/linux/man-pages/man3/backtrace.3.html

Alfred

@alfredh alfredh closed this as completed May 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants