Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!husc6!psuvax1!gondor.psu.edu!flee From: flee@gondor.psu.edu (Felix Lee) Newsgroups: comp.unix.questions Subject: Error reporting (Re: Biff and the message "Where are you?") Message-ID: <3090@psuvax1.psu.edu> Date: Sun, 15-Nov-87 08:21:38 EST Article-I.D.: psuvax1.3090 Posted: Sun Nov 15 08:21:38 1987 Date-Received: Mon, 16-Nov-87 04:30:17 EST References: <173@tarski.quintus.UUCP> <9312@mimsy.UUCP> <4110@watdragon.waterloo.edu> Sender: netnews@psuvax1.psu.edu Reply-To: flee@gondor.psu.edu (Felix Lee) Organization: The Roadside Picnic Lines: 29 In article <4110@watdragon.waterloo.edu> jmsellens@watdragon.waterloo.edu (John M. Sellens) writes: > If I may, I would like to propose some error message guidelines, > which some of you undoubtedly will think of as obvious. [various obvious things...] int errorf(char *format, ...); void xerrorf(int exitcode, char *format, ...); Report an error, using printf-like arguments. '%m' gets expanded to sys_errlist[errno] (similar to BSD syslog(3)). Umm, how about '%p' getting expanded to basename(argv[0])? xerrorf() will also exit(). So you can say xerrorf(42, "%p: can't open '%s': %m\n", filename); Is there a commonly-accepted error function? Does POSIX provide a standard error function (other than perror)? > - Always use exit() to set the exit status of your program. Unix doesn't make exit status visible enough. Unless you program in shell, you probably don't pay much attention to exit status. VM/CMS will show non-zero return codes in your prompt. In Unix, you have to say "echo $status" or "echo $?" explicitly. Csh at least shows exit status of background jobs. With ksh you could probably put $? in your prompt. Because of high visibility, most of CMS's utilities have return codes with well-defined meanings. Unix programs tend not to make distinctions other than true and false. Notable exceptions are fsck and . -- Felix Lee flee@gondor.psu.edu {cbosgd,cmcl2}!psuvax1!gondor!flee