Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site proper.UUCP Path: utzoo!watmath!clyde!burl!ulysses!harpo!seismo!hao!hplabs!intelca!proper!gam From: gam@proper.UUCP (Gordon Moffett) Newsgroups: net.unix,net.lang.c Subject: 'exit(1);' considered useless (slight flame) Message-ID: <957@proper.UUCP> Date: Tue, 7-Feb-84 01:01:16 EST Article-I.D.: proper.957 Posted: Tue Feb 7 01:01:16 1984 Date-Received: Wed, 8-Feb-84 00:39:00 EST Organization: Proper UNIX, San Leandro, CA Lines: 37 As a maintainer and supporter of existing software, I am getting tired of programs whose terminating action is: exit(1); A typical application is: p = malloc(n); if (p == NULL) { exit(1); } Bad enough that the original programmer didn't code for an error message, but furthermore was content to just provide a `non-zero' error code. In intro(2) of volume 1 of the Unix manual set are described the various error codes returned by system calls and subroutines. There is an external variable (int) called `errno' where these error codes are stored when applicable. So, programmers, please use: exit(errno); ... whenever possible, so I don't have to recode it for you. It is useful to reference the exit status of a command and have it provide more meaningful information that just a non-zero value. Thank you. SEE ALSO perror(3) "lint vs. strong typing - programmers' responsibitly", Usenet: net.lang -- Gordon A. Moffett { allegra, decvax!decwrl } !amd70!proper hplabs!intelca!proper!gam