🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #2162

Re: return vs. exit(), ANSI vs. POSIX

#2162
From: Joe Wright
Date: Wed, 30 Sep 1992 03:36
13 lines
1133 bytes
Dunno about yours, my compiler does all sorts of housekeeping
and command line parsing before calling main:.  The return from
main: falls into exit: and sets errno, closes open files and
then gracefully quits.  Returning from main() and calling exit()
have the same effect.  From main(), 'return 0;' and 'exit(0);'
are identical.  exit() is a function call and its argument is
stacked.  The exit() routine itself ignores the stack and takes
its argument from a register as if 'return' was encountered or
main() simply fell to the closing '}' brace.  exit() resets the
stack pointer as it was when the program was first executed.

-- 
Joe Wright  alpha@waggen.twuug.com  
Technical Details
Message-ID: <1992Sep30.033640.2194@waggen.twuug.com>
Path: arc1-ca.pugleaf.net!sparky!uunet!usc!sdd.hp.com!uakari.primate.wisc.edu!daffodil!wyvern!waggen!alpha
References: <1992Sep28.182846.2095@thinkage.on.ca>

Show Full Headers
Complete Article Headers
Newsgroups: comp.std.c
Path: arc1-ca.pugleaf.net!sparky!uunet!usc!sdd.hp.com!uakari.primate.wisc.edu!daffodil!wyvern!waggen!alpha
From: alpha@waggen.twuug.com (Joe Wright)
Subject: Re: return vs. exit(), ANSI vs. POSIX
Message-ID: <1992Sep30.033640.2194@waggen.twuug.com>
Organization: ALPHA, Box 68621, Va. Beach, VA 23455
X-Newsreader: TIN [version 1.1 PL6]
References: <1992Sep28.182846.2095@thinkage.on.ca>
Date: Wed, 30 Sep 1992 03:36:40 GMT
Lines: 13