Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!burl!ulysses!bellcore!decvax!decwrl!sun!guy From: guy@sun.UUCP Newsgroups: net.unix-wizards,net.bugs.4bsd Subject: Re: C startup in /lib/crt0.o Message-ID: <3592@sun.uucp> Date: Mon, 28-Apr-86 13:59:43 EDT Article-I.D.: sun.3592 Posted: Mon Apr 28 13:59:43 1986 Date-Received: Thu, 1-May-86 04:04:36 EDT References: <100@cstvax.UUCP> Organization: Sun Microsystems, Inc. Lines: 27 Xref: watmath net.unix-wizards:17841 net.bugs.4bsd:2075 > I see that the C startup routine _start in /lib/crt0.o under 4.2BSD > is a bit over-protective, in that it calls routine _exit (rather than > the system-call __exit) when it terminates. > (At least, this is the case >here< - I don't know if its very standard!) Yes, it is extremely standard. Just about every UNIX implementation of C does it (S3, S5, 4.xBSD, probably V7). > Does anyone know why? (or care, for that matter). In most UNIX implementations of C, if "main" returns with a given value, the program acts as if "exit" had been called as if "exit" had been called with that value. (Yes, I already know Sun UNIX doesn't do this.) This is implicitly stated in the S5 documentation, and very explicitly stated in the draft ANSI standard for C. It has nothing whatsoever to do with "over-protectiveness"; it's a matter of the semantics of the routine "main". > I suppose it does no harm really (except load in 4k of stdio-library > garbage, which I could really cope without!). It only does so in systems like 4.xBSD, which have removed the trick in the C library which causes the standard I/O library to be brought in only if it was actually used. This trick dates back to V7, and is still in S3 and S5. -- Guy Harris {ihnp4, decvax, seismo, decwrl, ...}!sun!guy guy@sun.arpa