Re: Why no segmentation fault



"santosh" <santosh.k83@xxxxxxxxx> writes:
Eric Sosman wrote:
[...]
Okay, I conceed that exotic systems like VMS might accept numerous
return values as condition codes. But still, 0 and EXIT_SUCCESS
*should* mean the same thing. If not then the system/library is
second-guessing the programmer. Other implementation specified macros
could be defined for indicating various types of sucesses and failures
but EXIT_SUCCESS and 0 should mean the same thing.

The host environment can assign any meaning to any particular return
value as it is not constrained by the C standard, but the C library
should ensure that 0 and EXIT_SUCCESS, as well as EXIT_FAILURE, are
mapped to the host recognised values for successful termination and
unsuccessful termination in the respective cases.

IMHO, a cleaner solution would have been for the C standard to specify
only EXIT_SUCCESS and EXIT_FAILURE as portable exit codes, leaving the
behavior of both 0 and 1 unspecified.

In the Unix world that gave birth to C, 0 means success, and non-zero
(particularly 1) means failure. The C standard chose to require 0 to
mean success on all systems, which, as we've seen, caused problems for
VMS.

On the other hand, if only EXIT_SUCCESS and EXIT_FAILURE were defined,
then almost all programs would have to have a "#include <stdlib.h>" to
see the definitions -- and all pre-ANSI code would have become
non-portable.

--
Keith Thompson (The_Other_Keith) kst-u@xxxxxxx <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
.



Relevant Pages

  • Re: A simple parser
    ... success, EXIT_FAILURE for failure. ... indicate *success* to the calling environment. ... It's often possible to define return values other than the standard ... Other error codes could be syntax error in ...
    (comp.lang.c)
  • Re: return from main
    ... represent successful termination but the Standard ... Under VMS, the OS convention is that returning an even number from a program indicates success, and returning an odd number indicates failure. ... As I recall, EXIT_SUCCESS is defined as 0, and EXIT_FAILURE is defined as some non-zero even number. ... The C standard broke the latter, ...
    (comp.lang.c)
  • Re: CDT-5
    ... The codes come out every two years right now. ... A good PMS is far too important a part of a dental practice. ... > That's one of the reasons I quit the ADA. ... >> this standard, but charges us to obtain a copy of the standard once ...
    (sci.med.dentistry)
  • [PATCH 01/16] trivial: fix assorted "success" typos
    ... Subject: trivial: fix assorted "success" typos ... error code otherwise. ... + * called once we have a lock from a successful search ... Return codes ...
    (Linux-Kernel)
  • Re: on buffer overflows and insecurity
    ... Clearly the standard cannot specify codes for all ... possible errors in all possible implementations. ... such as requiring more functions to set ...
    (comp.lang.c)