Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!linus!philabs!cmcl2!harvard!caip!seismo!mcvax!vmucnam!lri!rd From: rd@lri.UUCP (Roland Dirlewanger) Newsgroups: net.unix-wizards,net.bugs.4bsd Subject: Re: C startup in /lib/crt0.o Message-ID: <109@lri.UUCP> Date: Tue, 29-Apr-86 09:55:47 EDT Article-I.D.: lri.109 Posted: Tue Apr 29 09:55:47 1986 Date-Received: Sat, 3-May-86 01:46:20 EDT References: <100@cstvax.UUCP> Reply-To: rd@lri.UUCP (Roland Dirlewanger) Organization: LRI, Orsay. France Lines: 35 Xref: linus net.unix-wizards:14960 net.bugs.4bsd:1766 In article <100@cstvax.UUCP> simon@cstvax.UUCP (Simon Brown) writes: > >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!) > >Does anyone know why? (or care, for that matter). >I suppose it does no harm really (except load in 4k of stdio-library >garbage, which I could really cope without!). It is standard, and in almost every Unix system. This needed to flush all the buffering done by the stdio-library when your process exits. If you don't use the stdio package, adding these few lines to your programs will avoid these 4K of garbage to be loaded: exit (n) { return _exit (n); } Question: How standard is the stdio package ? I had some troubles with it, especially on a SUN 2 (may be this bug has been corrected in the new 3.0 version of SUN's system). Using stdio's printf caused the next malloc to return a non-aligned pointer. Using it as pointer to a short integer obviously core dumped. Personnaly, I don't use the stdio package. I have rewritten from scratch my own printf, sprintf and fprintf (except for floatting point numbers) and I use only reads and writes for accessing files (sometimes I have to do buffered I/O myself, if I don't want to access files one character at a time). Roland Dirlewanger