Path: utzoo!attcan!utgpu!news-server.csri.toronto.edu!mailrus!uwm.edu!zaphod.mps.ohio-state.edu!samsung!uunet!zephyr.ens.tek.com!uw-beaver!sumax!polari!6sigma2 From: 6sigma2@polari.UUCP (Brian Matthews) Newsgroups: comp.lang.c Subject: Re: main() [exit vs. return] Message-ID: <2179@polari.UUCP> Date: 7 Jul 90 16:07:55 GMT References: <4249@jato.Jpl.Nasa.Gov> <306@taumet.com> <4aZDy6i00Vtq8qIVAw@andrew.cmu.edu> Organization: Seattle Online Public Unix (206) 328-4944 Lines: 15 In article <4aZDy6i00Vtq8qIVAw@andrew.cmu.edu> ghoti+@andrew.cmu.edu (Adam Stoller) writes: |If one uses exit() [with argument EXIT_SUCCESS (?)] - I believe ANSI |specifies that any functions that were registered via the atexit() |function should be called prior to the final termination of the program. |If one uses return from main() do the functions registered with atexit() |get called ? (i.e. just how equivelent are they?) You're looking at it backwards. The standard doesn't say "we looked at all of the things exit and return from main do, and they look the same, so we'll say they're equivalent." It says "exit and return from main are equivalent" (paraphrasing slightly :-)). Thus if exit causes the atexit functions to run, a return from main must also, even if the standard doesn't explicitly say this anywhere. -- Brian L. Matthews blm@6sceng.UUCP