🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #3824

Re: EXIT_FAILURE problem

#3824
From: Derick J.R. Qua-Gonzalez
Date: Wed, 23 Aug 1995 05:38
74 lines
3019 bytes
In comp.lang.c and comp.std.c, caip.rutgers.edu!halasz writes:

>In article <411j5n$3va@goanna.cs.rmit.edu.au>,
>ok@goanna.cs.rmit.edu.au (Richard A. O'Keefe) writes:

>:  ....  An operating system can use any status convention it likes.
>: VMS status codes are really packed records, with "severity",
>: "source", and other fields.  If I recall correctly, Plan 9 uses
>: strings.  The B6700 MCP allowed arbitrary 48-bit patterns, some of
>: which were integers and most of which weren't.

>Yes, and the declaration of "exit", "main", and "exit(0)" require that this
>be hidden from the C-programmer, and that is a mistake.

The problem with this approach is exactly the variance in the exit
"codes" accepted by different systems. Then we'd be forced to
compensate with something that looks like:

        #ifdef OS_VMS
           exit(1);
        #endif

        #ifdef OS_B6700_MCP
           exit(B6700_MCP_EXIT_SUCCESS);
        #endif

        #ifdef OS_PLAN_9
           exit("Whee! It worked!");
        #endif

        #ifdef OS_UNIX
           exit(0);
        #endif

Eventually people would just write a function that looks like:

        void my_exit(int x)
        {
           switch (x) {
              /* a mess of #ifdef ... #endif blocks like above
                 for various cases */
              }
        }

just so that the termination can be written succintly as:

        if (severe_error_happened_OUCH)
           my_exit(-1);

  or:   if (i_am_all_done_so_terminate)
           my_exit(0);

The way ISO 9899:1990 does it is _much_ cleaner and promotes uniformity
and portability.

>No, the standard in effect prohibits all other valus [sic] than the
>required, by requiring "exit(0)" to be effectivlie [sic] the same as
>"exit(EXIT_SUCCESS)". In this respect, quite simplie [sic] the
>standard is wrong.

What prevents the exit function from appropriately translating?

BTW, where in the heck did you learn(?) to spell so horribly?  :-)

Best regards,
Derick.
--
+------------------------------------------------------------------------+
| Derick R. Qua-Gonzalez                                      | ________ |
| Department of High Energy Physics, Cal State University     | \      / |
| dqua@dqua.EarthLink.Net                                     |  \    /  |
|     ``It is better to be hated for what one is,             |   \  /   |
|       than loved for what one is not.'' (A. Gide)           | G  \/ USA|
+-------------------------------------------------------------+----------+
Technical Details
Message-ID: <dqua.809156287@dqua>
Path: arc1-ca.pugleaf.net!nntp.earthlink.net!dqua!dqua
References: <jbundyDCw7uo.9sz@netcom.com> <danpop.807723059@rscernix> <411j5n$3va@goanna.cs.rmit.edu.au> <41b3uv$s7@caip.rutgers.edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!nntp.earthlink.net!dqua!dqua
From: dqua@earthlink.net (Derick J.R. Qua-Gonzalez)
Newsgroups: comp.std.c
Subject: Re: EXIT_FAILURE problem
Date: 23 Aug 95 05:38:07 GMT
Organization: Earthlink Network, Inc.
Message-ID: <dqua.809156287@dqua>
References: <jbundyDCw7uo.9sz@netcom.com> <danpop.807723059@rscernix> <411j5n$3va@goanna.cs.rmit.edu.au> <41b3uv$s7@caip.rutgers.edu>
NNTP-Posting-Host: dqua.earthlink.net