Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!cbatt!ihnp4!qantel!hplabs!sdcrdcf!ucla-cs!rutgers!topaz!ll-xn!nike!lll-crg!seismo!sundc!netxcom!hadron!jsdy From: jsdy@hadron.UUCP (Joseph S. D. Yao) Newsgroups: net.lang.c Subject: Re: functions that don't return Message-ID: <1804@curly.ucla-cs.ARPA> Date: Mon, 29-Sep-86 16:32:16 EDT Article-I.D.: curly.1804 Posted: Mon Sep 29 16:32:16 1986 Date-Received: Sat, 4-Oct-86 06:02:41 EDT References: <28@tl-vaxa.UUCP> <86900066@haddock> Reply-To: jsdy@hadron.UUCP (Joseph S. D. Yao) Organization: Hadron, Inc., Fairfax, VA Lines: 26 Summary: How do you exit if you take away exit()? Answer: In article <86900066@haddock> karl@haddock writes: >if you supersede exit() with a function that returns, how do you get out of >the program? Send yourself a signal? Most crt0.s's or the like contain code similar to: store-args argc, argv, envp call-function _main call-function _exit system-call exit halt If exit() is re-defined to return, the system call will exit after a return from main(). The 'halt' usually causes a trap if neither works. Using 'return' from main() is the preferred way to exit according to System V lint (which complains otherwise). I've preferred it myself, for years before, because I've viewed exit() as a glitch in a smooth mental model of the invocation and return of routines. THIS (latter) IS PURELY PERSONAL PREFERENCE, NO FLAMES DESIRED, but comments on s5lint's and others' mental models welcome. -- Joe Yao hadron!jsdy@seismo.{CSS.GOV,ARPA,UUCP} jsdy@hadron.COM (not yet domainised)