functions that don't return
Joseph S. D. Yao
jsdy at hadron.UUCP
Mon Sep 29 22:38:23 AEST 1986
In article <86900066 at haddock> karl at 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 at seismo.{CSS.GOV,ARPA,UUCP}
jsdy at hadron.COM (not yet domainised)
More information about the Comp.lang.c
mailing list