Path: utzoo!mnetor!uunet!seismo!sundc!pitstop!sun!imagen!qubix!wjvax!brett From: brett@wjvax.UUCP (Brett Galloway) Newsgroups: comp.lang.c Subject: Re: exit(-1) Message-ID: <1179@wjvax.UUCP> Date: 7 Jan 88 02:36:36 GMT References: <502@cresswell.quintus.UUCP> <6935@brl-smoke.ARPA> Reply-To: brett@wjvax.UUCP (Brett Galloway) Organization: Watkins-Johnson Co., San Jose, Calif. Lines: 44 In article <6935@brl-smoke.ARPA> gwyn@brl.arpa (Doug Gwyn (VLD/VMB) ) writes: >In article <502@cresswell.quintus.UUCP> ok@quintus.UUCP (Richard A. O'Keefe) writes: >>Except where you are writing code for a specific system (say you >>have #if cases for MVS, VMS, and UNIX) it seems like a good idea >>to pass only 0 or 1 to exit(). > >VMS C would like for exit(1); to also mean "success", we were told, >so the current proposed standard requires to define macros >EXIT_FAILURE and EXIT_SUCCESS. Special dispensation was granted to >the value 0, which also indicates success (the VMS C implementor >agreed that he could make that work on his system). All other values >of the exit status have implementation-defined meaning; they might >contain system error codes, errno values, or some other stuff with >non-portable meaning. It appears to me that requiring EXIT_FAILURE and EXIT_SUCCESS is a sop to VMS's non-traditional usage. Now I grant that it is a nice idea to define EXIT_FAILURE and EXIT_SUCCESS. I also grant that other exit values are implementation-defined. However, it is hard to conceive an implementation which has multiple exit-success values. In this context, 0 is by far the most intuitive choice for EXIT_SUCCESS. Instead of accommodating VMS's stupid choice of exit values, why not require an ANSI-conforming VMS C compiler to swap 0 and 1 in the exit() in its C library? That way, even if VMS wants to see 1 for success, it will, with C programs able to return the natural value of 0 for success. I seem to recall that VMS already defines macros for error return values. It could swap those (make 0 success). This way, currently-compiled VMS C binaries would continue to run, and newly-compiled C binaries would also work (they would get the swapped exit() *and *the new EXIT_FAILURE and EXIT_SUCCESS macros at the same time. The only time that there would be a problem would be a re-link without a re-compile. Frankly, anybody that would not re-compile across a transition to an ANSI-conformant compiler deserves what they get. This solves the problem for everybody, while leaving conformant the vast body of programs which use the natural exit(0) => success and exit(!0) => !success. It puts the burden of conformance upon VMS instead of upon the rest of the world. This is apt, since VMS caused the problem in the first place. -- ------------- Brett D. Galloway {ac6,calma,cerebus,isi,isieng,pyramid,tymix}!wjvax!brett