🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #3993

Re: EXIT_FAILURE problem

#3993
From: Mike Schilling
Date: Wed, 13 Sep 1995 20:10
43 lines
2892 bytes
Jeremy Fitzhardinge (jeremy@sw.oz.au) wrote:
: In <1995Sep11.221423.6651@forte.com> mikes@forte.com (Mike Schilling) writes:
: >Why couldn't the standard define another function called, say 
: >
: >	void sys_exit(OS_RET_TYPE)
: >
: >which does what exit does in terms of cleanup, and then exits with 
: >OS-specific exit status.  The standard couldn't specify the actual type
: >of OS_RET_TYPE, of course, or how to map OS-specific exit statuses into
: >C types.  Much of the usefulness of sys_exit *would* be a quality of 
: >implementation issue.  Still, writing largely portable programs which 
: >use OS-specific features where possible and appropriate would be far eaiser
: >if this kind of thing were encouraged and where possible mandated.
: 
: This is getting pretty silly.  Why have the standard define something
: completely undefined?  It would be impossible for a conforming program
: to use such a sys_exit() without knowing what OS_RET_TYPE is, which
: means it can't be used unless a specific OS is targeted, which means it
: would be non-portable.  There's no point in having the standard define
: a feature which can't be used portably.

What is the purpose of a standard?  If it's purely to distinguish
conforming from non-conforming implementations, then this *is* useless;
no test could determine whether it's implemented in a conforming way or not.

Suppose, on the other hand, it's to help people write portable programs.
It's unavoidable that portable programs will sometimes need to use 
system-specific services.  The best way (IMHO) to do this is to create
a portable abstraction and implement that abstraction on the target
platforms.  I'm suggesting as portable an abstraction as possible, and
suggesting that the compiler vendor implement it.  The alternative is
for each user who needs it to implement it, which requires digging into the
internals of each implementation of 'exit' to try to separate the portable
part (closing files, calling atexit functions, etc.), which is still 
required, from the non-portable part (returning status to the OS),
which needs to be replaced.

Yes, the use of sys_exit would have to be ifdef'd (or put in a system-
specific file) but it would be far more convenient for a developer 
porting to a new system to code the proper variant of the sys_exit
call than to investigate the C exit implementation and the OS system
call which exits, and then decide how to combine the two.  Isn't
making life easier for developers the purpose of language standards?
Technical Details
Message-ID: <1995Sep13.201030.20883@forte.com>
Path: arc1-ca.pugleaf.net!uucp3.netcom.com!forte!mikes
References: <jeremy.810996048@suede.sw.oz.au>

Show Full Headers
Complete Article Headers
Newsgroups: comp.std.c
Path: arc1-ca.pugleaf.net!uucp3.netcom.com!forte!mikes
From: mikes@forte.com (Mike Schilling)
Subject: Re: EXIT_FAILURE problem
Message-ID: <1995Sep13.201030.20883@forte.com>
Organization: Forte Software Inc.
X-Newsreader: Tin 1.1 PL5
References: <jeremy.810996048@suede.sw.oz.au>
Date: Wed, 13 Sep 1995 20:10:30 GMT