Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site hou3c.UUCP Path: utzoo!watmath!clyde!burl!hou3c!ka From: ka@hou3c.UUCP (Kenneth Almquist) Newsgroups: net.unix,net.lang.c Subject: Re: 'exit(1);' considered useless (slight flame) Message-ID: <232@hou3c.UUCP> Date: Thu, 2-Feb-84 14:09:51 EST Article-I.D.: hou3c.232 Posted: Thu Feb 2 14:09:51 1984 Date-Received: Wed, 8-Feb-84 01:25:29 EST References: <957@proper.UUCP> Organization: Bell Labs, Holmdel, NJ Lines: 19 The example given, in which a program exits in the case of an error without printing an error message, is probably an unforgivable action on the part of the programmer. (The exception would be if the program is not intended to be run by users, such as a mail delivery program.) However, I don't think that using errno as the exit status is a particularly good convention because knowing the value is errno is often not much use if you don't know which system call failed, and more importantly, why the program was trying to execute the system call in the first place. Furthermore, the convention does not deal with errors that are not due to system calls failing. In my experience a simple succeeded/failed error indication, combined with a more informative printed error message, is adequate for almost all pro- grams. However, if a more detailed error indication is needed, a list of error codes which relate to the function of the program should be constructed. The "zero = successs" convention is universal enough that all programs should follow it. Beyond that, however, there is no widely accepted convention, so the error codes might as well be chosen to describe the possible errors clearly. Kenneth Almquist