[OT]-ish: Can someone explain this?

Paul Johnson paul at pjcj.net
Mon Jul 4 20:00:17 BST 2011


On Mon, Jul 04, 2011 at 06:59:46PM +0100, Andrew Suffield wrote:
> On Mon, Jul 04, 2011 at 04:40:48PM +0100, David Cantrell wrote:
> > On Sat, Jul 02, 2011 at 05:32:38PM +0100, Dirk Koopman wrote:
> > 
> > > Here is a bit of C code that is part of something much bigger.
> > > 
> > > 	_exit(0);	
> > 
> > Why _exit instead of exit?
> > 
> > exit() DTRT with flushing filehandles.
> 
> Yeah, I forgot to say earlier:
> 
> You almost never want to call _exit() unless you're implementing libc
> or doing evil things with fork().

If you have a program which allocates large dynamic data structures,
cleaning up those structures when the program terminates can be quite
expensive.  Judicious use of _exit(), particularly in C++, can (could?)
be the difference between a program ending almost immediately and a very
noticeable delay.

-- 
Paul Johnson - paul at pjcj.net
http://www.pjcj.net


More information about the london.pm mailing list