Article View: net.lang.c
Article #9432Re: functions that don't return
From: Joseph S. D. Yao
Date: Mon, 29 Sep 1986 12:38
Date: Mon, 29 Sep 1986 12:38
26 lines
1562 bytes
1562 bytes
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)
Technical Details
Message-ID:
<584@hadron.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!mnetor!seismo!sundc!netxcom!hadron!jsdyReferences:
<28@tl-vaxa.UUCP> <86900066@haddock>Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: arc1-ca.pugleaf.net!utzoo!mnetor!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: <584@hadron.UUCP> Date: Mon, 29-Sep-86 08:38:23 EDT Article-I.D.: hadron.584 Posted: Mon Sep 29 08:38:23 1986 Date-Received: Wed, 1-Oct-86 01:09:57 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: