Subject: Re: a few minor cleanups to src/share/misc/style
To: Greywolf <greywolf@starwolf.com>
From: Chris G. Demetriou <cgd@sibyte.com>
List: tech-kern
Date: 03/21/2001 19:16:37
Greywolf <greywolf@starwolf.com> writes:
> Can I ask what the point is of (strongly) suggesting such things as
> EXIT_SUCCESS and EXIT_FAILURE as opposed to 0 and 1? That just
> seems such a PITA.
(1) They're more portable. I.e., really, not all systems which support
'standard C' use success == 0 and failure == non-zero. Sure, those
systems aren't really unix, but since KNF already says 0 / 1, it seems
fairly obvious and non-bad to use the standards-defined exit codes.
(2) They have immediately-obvious meaning. If you're coming up to
UNIX code for the first time, what do you think: is 0 or 1 success or
failure? (Why is it intuitively obvious that it should be different
than, say, true or false booleans?) EXIT_* makes the code a bit more
self-documenting.
> The other thing is what if you need to denote different conditions
> via different exit stats (as in success, failure-because-of-runtime-
> criteria-mismatch, failure-because-of-resource-unavailability)?
> i.e., what if it's possible for something to fail in several different
> ways? I think it'd be the polite thing to do to provide (and document)
> several different exit codes.
That's been "prohibited" by KNF forever.
As with many things, if there's a good, strong reason to do otherwise,
then it's reasonable. But for random failures of a program, there's
no great reason to differentiate.
cgd