Article View: comp.std.c
Article #3368Re: EXIT_FAILURE problem
From: Richard A. O'Keefe
Date: Fri, 18 Aug 1995 08:31
Date: Fri, 18 Aug 1995 08:31
40 lines
2502 bytes
2502 bytes
halasz@caip.rutgers.edu writes:
>What is this but to decree that 0 is success, whatevver the OS s custom is?
How soon they forget.
"There is no such thing as a standard interface to a non-standard feature".
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.
The thing is, if you want to access some facility which is not in the C
standard, you have to use a function that is not in the C standard to do it.
The exit() function says NOTHING about what status codes the operating system
has to use. What the standard is saying is
-- if you want to use the "native" status codes in some operating system,
you will have to use a "native" function to do that, and it isn't the
_C_ standard's business to dictate what _that_ function looks like.
-- if you want a PORTABLE way to terminate with success/failure, use
exit(0) or exit(EXIT_SUCCESS)/exit(EXIT_FAILURE)
-- if exit(N) for some other value of N happens to be useful in your
operating system, that's nice, but "You didn't read it here".
It has been a long time since I used VMS or VAX-11 C, but I thought there
was a SYS$EXIT(longword) function you could use to terminate "natively".
Zero has to mean success AS FAR AS THE exit() FUNCTION IS CONCERNED,
because exit() is governed by the C standard.
Zero does NOT have to mean success as far as any other function is concerned.
Now _my_ pet peeve is the way so much crud-for-UNIX code uses exit(-1),
when UNIX status codes are 0..255.
--
"conventional orthography is ... a near optimal system for the
lexical representation of English words." Chomsky & Halle, S.P.E.
Richard A. O'Keefe; http://www.cs.rmit.edu.au/~ok; RMIT Comp.Sci.
Technical Details
Message-ID:
<411j5n$3va@goanna.cs.rmit.edu.au>Path:
arc1-ca.pugleaf.net!goanna.cs.rmit.edu.au!not-for-mailReferences:
<jbundyDCw7uo.9sz@netcom.com> <danpop.807723059@rscernix> <Ik_SXNiSMUE48zNeor@transarc.com> <40escg$bud@caip.rutgers.edu>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!goanna.cs.rmit.edu.au!not-for-mail From: ok@goanna.cs.rmit.edu.au (Richard A. O'Keefe) Newsgroups: comp.std.c,comp.lang.c Subject: Re: EXIT_FAILURE problem Date: 18 Aug 1995 18:31:51 +1000 Organization: Comp Sci, RMIT, Melbourne, Australia Message-ID: <411j5n$3va@goanna.cs.rmit.edu.au> References: <jbundyDCw7uo.9sz@netcom.com> <danpop.807723059@rscernix> <Ik_SXNiSMUE48zNeor@transarc.com> <40escg$bud@caip.rutgers.edu> NNTP-Posting-Host: goanna.cs.rmit.edu.au NNTP-Posting-User: ok X-Newsreader: NN version 6.5.0 #0 (NOV)