LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-18-2010, 11:54 PM   #1
wagaboy
Member
 
Registered: Jun 2010
Distribution: Ubuntu 10.04, Cent OS 5.5, CLE3
Posts: 51

Rep: Reputation: 21
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.
 
Click here to see the post LQ members have rated as the most helpful post in this thread.
Old 09-19-2010, 06:51 AM   #2
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian, Arch
Posts: 3,780

Rep: Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081
man atexit(3)
 
3 members found this post helpful.
Old 09-20-2010, 04:26 AM   #3
wagaboy
Member
 
Registered: Jun 2010
Distribution: Ubuntu 10.04, Cent OS 5.5, CLE3
Posts: 51

Original Poster
Rep: Reputation: 21
Thanks ! This is exactly what I was looking for.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
What are program Exit codes, where seen? skola Linux - General 10 12-19-2009 01:15 PM
[SVN - post-commit hook] hook failed, did not exit cleanly G00fy Programming 0 01-21-2009 02:15 AM
program exit return 0 or 1? blackzone Programming 4 07-20-2006 05:00 AM
A Program That Does the Mac Zoom Thing Animortis Linux - Software 2 03-18-2006 01:01 AM
Why isn't dhclient running my exit hook? eantoranz Ubuntu 2 06-27-2005 02:41 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:06 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration