Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!think!harvard!seismo!rlgvax!hadron!jsdy From: jsdy@hadron.UUCP (Joseph S. D. Yao) Newsgroups: net.lang.c,net.unix Subject: Re: return() vs. exit() vs. _exit() Message-ID: <202@hadron.UUCP> Date: Sun, 26-Jan-86 14:07:01 EST Article-I.D.: hadron.202 Posted: Sun Jan 26 14:07:01 1986 Date-Received: Thu, 30-Jan-86 04:51:08 EST References: <178@rexago1.UUCP> Reply-To: jsdy@hadron.UUCP (Joseph S. D. Yao) Distribution: net Organization: Hadron, Inc., Fairfax, VA Lines: 42 Xref: watmath net.lang.c:7690 net.unix:6959 Summary: return ~= exit > _exit In article <178@rexago1.UUCP> rich@rexago1.UUCP (K. Richard Magill) writes: >What's the difference between leaving main by return() vs exit() vs _exit()? Functionally, return and exit should be identical. Your 'lint' (s5r2.0v2) prob'ly complains if you use exit() tho. The code goes roughly like: [C header, crt0.s:] push envp push argv push argc call $3, _main push r0 call $1, $_exit sys $exit_system_call halt Note that exit(main(argc, argv, envp)) is the effect. The exit() code resembles: exit(val) int val; { register FILE *fp; for (fp = _iob; fp < &_iob[NIOBUFS]; fp++) if fp has been opened fclose(fp); _exit(val); } .......... __exit: move arg to r0 sys $exit_system_call Shared and local memory are reclaimed by the kernel after an exit() system call. > ... What is a gate 4, 8? Got my curiosity piqued. -- Joe Yao hadron!jsdy@seismo.{CSS.GOV,ARPA,UUCP}