handle SIGSEGV in Linux?

Posted by user303967 on Stack Overflow See other posts from Stack Overflow or by user303967
Published on 2010-06-10T06:48:04Z Indexed on 2010/06/10 6:52 UTC
Read the original article Hit count: 388

Filed under:
|
|
|

Hi all, I need handle the SIGSEGV in my Linux app. The reason is some clean up(3-partry lib) must be done before generate core-dump. What is more, the clean up must be performed in the context of calling thread, cannot do in signal handler. So I plan in signal handler to pass the control to the calling thread, after the clean up finished, then use raise(SIGSEGV) to generate the core-dump.

The real problem seems the signal_handler cannot pass the control to calling thread, no matter I use post_sem or some others. Any idea to handle this case? Possbile to hijack the SIGSEGV, then in SIGSEGV hander return to another thread to perform some clean up?

signal(SIGSEGV, signal_handler);

signal_handler() { ... post_sem(); ... }

calling thread() { wait_sem(); clean_up(); ... }

© Stack Overflow or respective owner

Related posts about linux

Related posts about handler