E
Eric Sosman
Mark McIntyre wrote On 03/27/06 16:37,:
<off-topic>
Sherman, set the Wayback Machine for the mid-1980's.
VMS "condition codes" were/are structured values with
multiple fields and sub-fields packed into thirty-two bits.
The low-order three bits were the "severity," and five of
the eight possible values were actually used: SUCCESS,
INFORMATIONAL, WARNING, ERROR, and FATAL. The lowest-order
bit summarized matters even more crudely: odd values were
successful (SUCCESS and INFORMATIONAL), while even values
indicated failures (WARNING, ERROR, FATAL).
Early on, the value passed to exit() or returned from
main() was simply treated as a VMS condition code, and was
handed straight back to the invoker unaltered. Alas, this
meant that C programs ported from Unix usually seemed to
fail when they succeeded and succeed when they failed, since
the exit statuses zero and one mapped to failure and success
instead of the other way around. For a while DEC tried to
persuade people to use native VMS condition codes (arguably
the Right Thing To Do as part of a port), but eventually
they threw in the towel and patched the VAXC library so it
mapped zero to one and one to zero while leaving other
status values unchanged (so a VMS-aware program could use
them to report more elaborate status information).
Once the ANSI Standard appeared, VAXC gained a few
ANSIfications (although it never fully complied to the
Standard; DEC brought out a completely new DECC compiler
and library as their Standard-compliant implementation.)
Among the ANSIisms were the <stdlib.h> header ("header,"
not "header file") and the EXIT_SUCCESS and EXIT_FAILURE
macros. These did not expand to 0 and 1 a la Unix, nor to
1 and 0 a la pre-surrender VMS, but to full-fledged VMS
condition codes, complete with Facility, Message, and
Severity fields.
Up-thread, Santosh asked rhetorically
Well, Santosh, VAXC on VMS was an implementation that
actually did so, and although VMS had many peculiarities
I don't think this really counts as one of them. An exit
status of zero (after translation to one) meant "Some kind
of success status emanating from an unspecified component
of the system," while EXIT_SUCCESS meant "Successful
completion of a VAXC program."
Mark McIntyre says he programmed in "VAX-C" some five
years ago, which seems rather recent for such an elderly
implementation. It's possible, I guess -- maybe he was
working on elderly code -- but DECC would have been a
more likely choice, certainly a more likely choice for
new code. In the days (considerably more than five years
agone) when I worked on VAXen, we never really transitioned
the existing code from VAXC to DECC -- in part because not
all our platforms had usable ANSI-conforming compilers,
and we didn't want to undertake the K&R-to-ANSI transition
until there was a good chance of bringing it off. And as
it turned out, "until" never came: That PPOE went into a
prolonged and painful death spiral, and nowadays exists
only as a brand name some other company bought.
</off-topic>
I think you may have this backwards, since I recall being able to
compile perfectly normal C code with VAX-C, but its at least five
years since I last programmed on a Vax so...
<off-topic>
Sherman, set the Wayback Machine for the mid-1980's.
VMS "condition codes" were/are structured values with
multiple fields and sub-fields packed into thirty-two bits.
The low-order three bits were the "severity," and five of
the eight possible values were actually used: SUCCESS,
INFORMATIONAL, WARNING, ERROR, and FATAL. The lowest-order
bit summarized matters even more crudely: odd values were
successful (SUCCESS and INFORMATIONAL), while even values
indicated failures (WARNING, ERROR, FATAL).
Early on, the value passed to exit() or returned from
main() was simply treated as a VMS condition code, and was
handed straight back to the invoker unaltered. Alas, this
meant that C programs ported from Unix usually seemed to
fail when they succeeded and succeed when they failed, since
the exit statuses zero and one mapped to failure and success
instead of the other way around. For a while DEC tried to
persuade people to use native VMS condition codes (arguably
the Right Thing To Do as part of a port), but eventually
they threw in the towel and patched the VAXC library so it
mapped zero to one and one to zero while leaving other
status values unchanged (so a VMS-aware program could use
them to report more elaborate status information).
Once the ANSI Standard appeared, VAXC gained a few
ANSIfications (although it never fully complied to the
Standard; DEC brought out a completely new DECC compiler
and library as their Standard-compliant implementation.)
Among the ANSIisms were the <stdlib.h> header ("header,"
not "header file") and the EXIT_SUCCESS and EXIT_FAILURE
macros. These did not expand to 0 and 1 a la Unix, nor to
1 and 0 a la pre-surrender VMS, but to full-fledged VMS
condition codes, complete with Facility, Message, and
Severity fields.
Up-thread, Santosh asked rhetorically
Would it not be absurd for an implementation to return
"status" values of different kinds for exit(0) and
exit(EXIT_SUCCESS), [...]
Well, Santosh, VAXC on VMS was an implementation that
actually did so, and although VMS had many peculiarities
I don't think this really counts as one of them. An exit
status of zero (after translation to one) meant "Some kind
of success status emanating from an unspecified component
of the system," while EXIT_SUCCESS meant "Successful
completion of a VAXC program."
Mark McIntyre says he programmed in "VAX-C" some five
years ago, which seems rather recent for such an elderly
implementation. It's possible, I guess -- maybe he was
working on elderly code -- but DECC would have been a
more likely choice, certainly a more likely choice for
new code. In the days (considerably more than five years
agone) when I worked on VAXen, we never really transitioned
the existing code from VAXC to DECC -- in part because not
all our platforms had usable ANSI-conforming compilers,
and we didn't want to undertake the K&R-to-ANSI transition
until there was a good chance of bringing it off. And as
it turned out, "until" never came: That PPOE went into a
prolonged and painful death spiral, and nowadays exists
only as a brand name some other company bought.
</off-topic>