Article View: comp.std.c
Article #3938Re: EXIT_FAILURE problem
From: halasz
Date: Thu, 07 Sep 1995 02:18
Date: Thu, 07 Sep 1995 02:18
42 lines
3116 bytes
3116 bytes
In article <42k9vn$5co@newshost.lanl.gov>, tanmoy@qcd.lanl.gov (Tanmoy Bhattacharya) writes > How do macros help in this? You can have only a finite number of macros > _defined_ by the standard, the rest would be implementation defined. Two of > these macros will possibly indicate the general notions of success and > failure. The macros hide the actual exit-status from the programmer, lettind him pick them by name, but savind the poor soul from a filter that on most systems prevents him from uzing special implementational ones if he wants to. Specifying constants forses this needless filter into being, driving the local programmer into uzing local exit-routines instead of "exit". > What do you think the C library function 'exit' is for. The standard is > giving the implementation the opportunity of helping all its programmers by > writing a C library function called 'exit' which 'turns that exit-status that > he wishes his program to return into a real exit-status by calling the > relevant system-dependent exit-routine'. I do not understand why every > programmer will bother to write this routine when 'exit' already exists for > precisely this task: The input of exit is a high level description of what is > needed, coded into an integer in an implementation defined fashion: and the > 'output' is an appropriate error code returned to the system. None of this is more than partlie tru. Yes, "exit" is meant for this, but specifying the meaning of "exit(0)" obviates it, and makes "exit" useless for finer exit-status when the programmer wants it and knows that the system supports it. If all aspects of exit-status are hidden under typedef and macro then it is enough for such programmer to uze "#ifdef" on the valu passd to "exit"--0 under warning under VMS, and also for Unix for in Unix this notion is not uzed, 1 for the Guardian, and so on. If even one constant is specifyd then the programmer is obliged to include not onlie the argument but also the local function-name in his particular code, for "exit" prevents him from uzing 0 for anithing but success. Unhappilie, the programmer needs the type passd to "exit" and the return-type of "main" also hidden, for not all systems (it has been pointed out) uze a form of 'int'. On a new topic, "EXIT_SUCCESS" and "EXIT_FAILURE" are not enough. In practice Unix limits itself to 0, 1, and seldom 2, but four degrees are not rare; that is, also "EXIT_WARNING" if the program detects a lesser degree of truoble, and "EXIT_ERLIE" or "EXIT_ABORT" if the error is so bad that the program bails out. When under Unix a program uzes 2 it uzuallie means the last. Both VMS and the Guardian uze thismanie degrees, and more.
Technical Details
Message-ID:
<42lkqd$ngg@caip.rutgers.edu>Path:
arc1-ca.pugleaf.net!caip.rutgers.edu!not-for-mailReferences:
<jbundyDCw7uo.9sz@netcom.com> <danpop.807723059@rscernix> <42k9vn$5co@newshost.lanl.gov>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!caip.rutgers.edu!not-for-mail From: halasz@caip.rutgers.edu Newsgroups: comp.std.c Subject: Re: EXIT_FAILURE problem Date: 6 Sep 1995 22:18:53 -0400 Organization: Rutgers University Message-ID: <42lkqd$ngg@caip.rutgers.edu> References: <jbundyDCw7uo.9sz@netcom.com> <danpop.807723059@rscernix> <42k9vn$5co@newshost.lanl.gov> NNTP-Posting-Host: caip.rutgers.edu