main() and exit() (was: Strange lint mumblings)

Moshe Braner braner at batcomputer.tn.cornell.edu
Fri Dec 30 02:58:59 AEST 1988


On systems I have worked on, calling exit() links in most of the
STDIO library modules, resulting in an executable program that is
much bigger than it needs to be (in the case where you don't otherwise
use STDIO).  Calling _exit() instead does not link in STDIO.  Does
YOUR system's startoff code (that calls main()) call exit() or _exit()?
Do you like the way it is?

Other related observations/questions: exit() flushes stream I/O buffers.
It also closes the files (releases the descriptors).  Who closes non-STDIO
files (the ones you opened with open() rather than fopen())?  On my systems
it seems that the OS closes the files (although I always use explicit calls
to close() to be sure).

Finally, what percentage of YOUR programs do NOT use STDIO (buffered
streams, fopen/fread/putc/puts/printf...)?  I try and avoid STDIO when
programming small utilities for microcomputers, since they have small
memories, slow disks, and no shared libraries.  Also micro compilers come
with direct screen/keyboard I/O functions.

- Moshe Braner

Cornell Theory Center, 265 Olin Hall,
Cornell University, Ithaca, NY 14853
(607) 255-9401	(Work)
<braner at tcgould.tn.cornell.edu>		(INTERNET)
<braner at crnlthry> or <braner at crnlcam>	(BITNET)



More information about the Comp.lang.c mailing list