🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #3919

Re: EXIT_FAILURE problem

#3919
From: Richard A. O'Keefe
Date: Mon, 04 Sep 1995 08:52
55 lines
3045 bytes
baynes@ukpsshp1.serigate.philips.nl (Stephen Baynes) writes:
>Ih intended that if it is other than EXIT_SUCCESS or EXIT_FAILURE then it is 
>OS specific if it is regarded as a failure. I take your point that it is 
>useful to know if the other values are sucesses or failures. One could have 
>an EXIT_SUCCESS_MAX where 0..EXIT_SUCCESS_MAX are successes, 
>EXIT_SUCCESS_MAX+1..EXIT_MAX are failures.

This is a perfect example of why the C standard got it just right.

Where on earth did you get the idea that
(a) all the codes in each major category form an interval of integers
(b) the boundary between the intervals is fixed

(a) is false in VMS, where in the native status codes (used for all sorts
    of things, not just program termination) ODD means success and EVEN
    means failure.  There is no value of EXIT_SUCCESS_MAX which would
    make sense in that operating system.

(b) is false in DOS, where the ERRORLEVEL feature in .BATch files means
    that the boundary between success and failure is wherever the *caller*
    of the program wants it to be.

Me, I have my own version of Eric Allman's <sysexits.h> which does

#ifdef	USE_EXITS
#define EX_OK		0	/* successful termination */
#define EX_USAGE	64	/* command line usage error */
...
#define EX_LIMITED	79	/* resource limit hit */
#else
...
#define	EX_OK		EXIT_SUCCESS
#define EX_USAGE	EXIT_FAILURE	/* command line usage error */
....
#define EX_LIMITED	EXIT_FAILURE	/* resource limit hit */
#endif

It lets me make the distinctions I want to make, without sacrificing
portability (note that you have to take specific action to get the
non-portable version).

Thing is, suppose you know EXIT_MIN is 0 and EXIT_SUCCESS_MAX is 3.
What does that tell you?  It could be that
	0 => normal success
	1 => success but all files are to be removed
	2 => success but monitor should explode
	3 => success but libellous messages are to be posted to all groups
The semantics of program termination codes is intrinsically operating-
system specific.  Your program should not use the value EXIT_SUCESS_MAX
unless you *know* exactly what that is supposed to signify.

-- 
"conventional orthography is ... a near optimal system for the
 lexical representation of English words." Chomsky & Halle, S.P.E.
Richard A. O'Keefe; http://www.cs.rmit.edu.au/~ok; RMIT Comp.Sci.
Technical Details
Message-ID: <42eeoo$foo@goanna.cs.rmit.edu.au>
Path: arc1-ca.pugleaf.net!goanna.cs.rmit.edu.au!not-for-mail
References: <jbundyDCw7uo.9sz@netcom.com> <danpop.807723059@rscernix> <411j5n$3va@goanna.cs.rmit.edu.au> <41b3uv$s7@caip.rutgers.edu> <dqua.809156287@dqua> <DDt13K.K22@ukpsshp1.serigate.philips.nl> <41i2g9$brp@newshost.lanl.gov> <DDuwst.533@ukpsshp1.serigate.philips.nl>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!goanna.cs.rmit.edu.au!not-for-mail
From: ok@goanna.cs.rmit.edu.au (Richard A. O'Keefe)
Newsgroups: comp.std.c
Subject: Re: EXIT_FAILURE problem
Date: 4 Sep 1995 18:52:40 +1000
Organization: Comp Sci, RMIT, Melbourne, Australia
Message-ID: <42eeoo$foo@goanna.cs.rmit.edu.au>
References: <jbundyDCw7uo.9sz@netcom.com> <danpop.807723059@rscernix> <411j5n$3va@goanna.cs.rmit.edu.au> <41b3uv$s7@caip.rutgers.edu> <dqua.809156287@dqua> <DDt13K.K22@ukpsshp1.serigate.philips.nl> <41i2g9$brp@newshost.lanl.gov> <DDuwst.533@ukpsshp1.serigate.philips.nl>
NNTP-Posting-Host: goanna.cs.rmit.edu.au
NNTP-Posting-User: ok
X-Newsreader: NN version 6.5.0 #0 (NOV)