Article View: comp.std.c
Article #2162Re: return vs. exit(), ANSI vs. POSIX
From: Joe Wright
Date: Wed, 30 Sep 1992 03:36
Date: Wed, 30 Sep 1992 03:36
13 lines
1133 bytes
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!alphaReferences:
<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