View the Most Wanted LQ Wiki articles.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
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.


  Search this Thread
Old 09-12-2004, 01:50 AM   #1
Registered: Nov 2002
Posts: 57

Rep: Reputation: 15
trap command for c?

does c has the "trap" function or similiar function.

i.e run whenever the the program is ended or being killed.

Something like c++ destructor.
Old 09-12-2004, 02:38 AM   #2
Senior Member
Registered: Jan 2004
Location: Oregon, USA
Distribution: Slackware
Posts: 1,246

Rep: Reputation: 58
It's called atexit().
Old 09-12-2004, 07:01 AM   #3
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris10, Solaris 11, Mint, OL
Posts: 9,571

Rep: Reputation: 374Reputation: 374Reputation: 374Reputation: 374
See also "signal" or better "sigaction" for more general signal handling.
Old 09-13-2004, 05:06 AM   #4
Registered: Nov 2002
Posts: 57

Original Poster
Rep: Reputation: 15
setting signal handle is a tedious action...
i prefer atexit.


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
how to send snmp trap & recieve trap in C program minil Programming 3 07-10-2010 10:22 AM
Kernel trap (Fatal trap 12) m!k@EL *BSD 4 09-06-2007 12:58 AM
What is trap program?? Zero-0-Effect Linux From Scratch 2 09-17-2004 10:07 PM
trap signals AMMullan Programming 3 10-19-2003 05:31 PM
specific-trap? PTBmilo Linux - Security 6 05-26-2003 04:09 PM

All times are GMT -5. The time now is 02:40 AM.

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