call a function even a program terminate abnormally

Marcin Mielniczuk marmistrz.dev@zoho.eu
Sat Aug 5 09:31:00 GMT 2017


I guess you'd have to install handlers for every possible signal. Your program can receive SIGTERM, SIGKILL, ...

On August 5, 2017 11:29:51 AM GMT+02:00, Patrick Schlangen <patrick@schlangen.me> wrote:
>Hi Yubin,
>
>> I am wondering whether it is possible to invoke a function when a
>program
>> terminate abnormally (e.g., segfault).
>
>you could install a signal handler for SIGSEGV using signal() (2),
>but please be aware of all the pitfalls.
>
>When your process receives SIGSEGV, you probably have some
>memory corruption ongoing and you don't know if the data structure
>holding your lock is still valid.
>
>Best Regards,
>
>Patrick

-- 
Sent from my Android device with K-9 Mail. Please excuse my brevity.



More information about the Libc-help mailing list