LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
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-12-2004, 12:50 AM   #1
onnyloh
Member
 
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, 01:38 AM   #2
itsme86
Senior Member
 
Registered: Jan 2004
Location: Oregon, USA
Distribution: Slackware
Posts: 1,246

Rep: Reputation: 59
It's called atexit().
 
Old 09-12-2004, 06:01 AM   #3
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,789

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

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


Reply



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

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

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

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