Article View: comp.std.c
Article #3370Re: EXIT_FAILURE problem
From: caip.rutgers.eduhalasz
Date: Mon, 21 Aug 1995 23:13
Date: Mon, 21 Aug 1995 23:13
53 lines
3502 bytes
3502 bytes
halasz@caip.rutgers.edu writes: :What is this but to decree that 0 is success, whatevver the OS s custom is? 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. : .... : -- 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 Bad dezign in the standard. : _C_ standard's business to dictate what _that_ function looks like. No, it is the standard s bizness to take it from the OS. : -- if you want a PORTABLE way to terminate with success/failure, use : exit(0) or exit(EXIT_SUCCESS)/exit(EXIT_FAILURE) No, "exit(0)" is not portable, even if the standard decrees it. The _one_ portable means of handling this is to hide the valus under macro, and their types under a macro or defind type. : -- 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". No, the standard in effect prohibits all other valus than the required, by requiring "exit(0)" to be effectivlie the same as "exit(EXIT_SUCCESS)". : 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". Look, are we interested in C, or not? If we are, then we want the C-function to be permitted all of the OS s program-exits. : 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. In this respect, quite simplie the standard is wrong. The one grounds for requiring that "exit(0)" is permitted is backwards compatibilitie, but this is a case wherin far more is lost by it than gaind. All the code wherin this is doon was developd on a system where 0 alreddie means success, Unix or DOS or Guardian or ..., wherefore little is lost by not letting the code be blindlie coppied onto VMS or others ere the argument to "exit" is changed. The restriction on "exit" means that for all programmers the arguments are restricted to 0, "EXIT_SUCCESS", and "EXIT_FAILURE", even when the programmer knows that other status would in his case make more sens (not intendind to uze the code on other-like computers). Even the Unix- programmer is required to uze another function than exit, if he wants to exit with 2 or 3 or ..., much less the poor VMS-programmer, who would want to exit with 0 for to mark a general warning with no special content.
Technical Details
Message-ID:
<41b3uv$s7@caip.rutgers.edu>Path:
arc1-ca.pugleaf.net!caip.rutgers.edu!not-for-mailReferences:
<jbundyDCw7uo.9sz@netcom.com> <danpop.807723059@rscernix> <411j5n$3va@goanna.cs.rmit.edu.au>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!caip.rutgers.edu!not-for-mail From: caip.rutgers.edu!halasz Newsgroups: comp.std.c,comp.lang.c Subject: Re: EXIT_FAILURE problem Followup-To: comp.std.c Date: 21 Aug 1995 19:13:35 -0400 Organization: . Sender: halasz@caip.rutgers.edu Message-ID: <41b3uv$s7@caip.rutgers.edu> References: <jbundyDCw7uo.9sz@netcom.com> <danpop.807723059@rscernix> <411j5n$3va@goanna.cs.rmit.edu.au> NNTP-Posting-Host: caip.rutgers.edu