'exit(1);' considered useless (slight flame)

Kenneth Almquist ka at hou3c.UUCP
Fri Feb 3 05:09:51 AEST 1984


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



More information about the Comp.unix mailing list