LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 01-19-2008, 02:40 AM   #1
vijaya_svk
Member
 
Registered: Nov 2007
Posts: 61

Rep: Reputation: 15
what is the difference between exit() and _exit()


Hi
I am using exit() and _exit(), can u please tell me the difference between these two and what happens when an int value is passed to it,
that is exit(100) or _exit(100)
and also exit(0) or _exit(0).
 
Old 01-19-2008, 11:37 AM   #2
SciYro
Senior Member
 
Registered: Oct 2003
Location: hopefully not here
Distribution: Gentoo
Posts: 2,038

Rep: Reputation: 51
If you would have bothered to look at the manual, or even use google, you could plainly see that the argument is the exit status of the program, and _exit() simply exits the program without doing a cleanup, while exit() calls the proper cleanup codes first.
 
Old 01-20-2008, 10:16 PM   #3
ta0kira
Senior Member
 
Registered: Sep 2004
Distribution: FreeBSD 9.1, Kubuntu 12.10
Posts: 3,078

Rep: Reputation: Disabled
You would use _exit from a fork normally so that it doesn't try to clean up external things that the parent would (such as temp files or shared memory.)
ta0kira
 
Old 01-21-2008, 01:37 AM   #4
array lin
LQ Newbie
 
Registered: Nov 2007
Location: SuZhou, China
Posts: 12

Rep: Reputation: 0
When use exit, it will do some cleanup work, like closing file descriptor, file stream and so on, while _exit() does not.
 
Old 01-21-2008, 06:11 PM   #5
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,659
Blog Entries: 4

Rep: Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941
It is customary that routines whose names begin with one or more underscores are not intended for direct use by user-programs.
 
  


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
Exception Handling (difference between strderr, exit, abort, return) Darkhack Programming 1 02-27-2007 03:36 PM
Error while compiling kernel 2.4.20-8 (conflicting return type of _exit function) samkraju Red Hat 1 07-01-2006 06:41 AM
difference between _exit and exit??? moonz Linux - Newbie 3 01-20-2006 11:05 AM
difference between exit 1 and exit kushalkoolwal Programming 6 10-20-2005 03:56 PM
_exit() and exit() greghua Programming 3 10-08-2005 01:23 PM

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

All times are GMT -5. The time now is 06:48 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