Path: utzoo!mnetor!uunet!husc6!cmcl2!brl-adm!umd5!mimsy!chris From: chris@mimsy.UUCP (Chris Torek) Newsgroups: comp.lang.c Subject: Re: exit(n) vs return(n)-from-main Message-ID: <9876@mimsy.UUCP> Date: 18 Dec 87 22:05:23 GMT References: <10875@brl-adm.ARPA> <176@fxgrp.UUCP> <1286@laidbak.UUCP> Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742 Lines: 17 In article <1286@laidbak.UUCP> daveb@laidbak.UUCP (Dave Burton) writes: -They are NOT equivalent! -At least in the UNIX environment, exit() is a function that flushes all -buffers (and closes all file descriptors?), as well as handling functions -registered via onexit(), finally calling _exit(), a system call that -never returns. - -Using return instead of exit() bypasses this cleanup operation. If it does, the system is broken. exit(n) and return(n)-from-main are supposed to be equivalent. Among those systems that get it wrong are various releases of SunOS (where the difference was intentional, yet still wrong). -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7690) Domain: chris@mimsy.umd.edu Path: uunet!mimsy!chris