LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Such a thing as C program exit hook ? (https://www.linuxquestions.org/questions/programming-9/such-a-thing-as-c-program-exit-hook-833143/)

wagaboy 09-18-2010 11:54 PM

Such a thing as C program exit hook ?
 
I'm writing a library to collect some usage statistics, and it needs to be printed just before the program exists. Is there a way to call a function or a piece of code when the program is about to exit/terminate ? It's ok if the data is not printed during unusual circumstances like program crashes, but I want to print it just before normal termination of the code. Another restriction is that the data should be printed without requiring the library users to call it explicitly.

ntubski 09-19-2010 06:51 AM

man atexit(3)

wagaboy 09-20-2010 04:26 AM

Thanks ! This is exactly what I was looking for.


All times are GMT -5. The time now is 01:07 PM.