Article View: comp.std.c
Article #4022Re: EXIT_FAILURE problem
From: Philip Guenther
Date: Wed, 13 Sep 1995 06:38
Date: Wed, 13 Sep 1995 06:38
69 lines
3085 bytes
3085 bytes
In article <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.
I'm sorry, but I see *no* way to portably use sys_exit. Since
you have no idea what the type of its argument is, there's no way
to initialize or set _to_a_meaningful_value_ whatever you pass as
its argument.(*)
> 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 statement has left me almost speechless. I presume that you
think that your sys_exit() function is an example of such a
feature. Can you please provide an example of *portable* usage of
your sys_exit()? You'd like to encourage the usage of
implementation specific behaviour? What's the point of the
standard then?
The best the standard can do is provide way for a program to
stop, and provide at least one way to use this method with a
defined meaning. The standard actually goes beyond the minimum
in matching 'current practice' and provides *3* usages, with 2
defined meanings, and then says that if your environment can't
provide that much, it can only qualify as a freestanding
implementation. Poof, done. You want implementation defined
behavior, you know where to find it (eg, call a library function
not defined by the standard).
(*) I suppose you could do something like this:
int main(void)
{
OS_RET_TYPE foo;
char *q = "foo bar baz";
char *p = (char *)&foo;
memset(&foo, 0, sizeof(foo));
while ((p - (char *)&foo) < sizeof(foo)) {
*p++ = *q++;
*--p = '\0';
sys_exit(foo);
}
but while you've now initialized foo with a value of sorts, you
have no clue what this means to sys_exit().
Philip Guenther
----------------------------------------------------------------
Philip Guenther UNIX Systems and Network Administrator
Internet: guenther@gac.edu Phonenet: (507) 933-7596
Gustavus Adolphus College St. Peter, MN 56082-1498
I am _not_ a representative sample of the Gustavus Community. Yeah, right...
Source code never lies (it just misleads). (Programming by Purloined Letter?)
Technical Details
Message-ID:
<GUENTHER.95Sep13013822@lunen.gac.edu>Path:
arc1-ca.pugleaf.net!lunen.gac.edu!guentherReferences:
<42nsuq$bon@elf.bsdi.com> <1995Sep11.221423.6651@forte.com>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!lunen.gac.edu!guenther From: guenther@gac.edu (Philip Guenther) Newsgroups: comp.std.c Subject: Re: EXIT_FAILURE problem Date: 13 Sep 1995 06:38:22 GMT Organization: Gustavus Adolphus College, St. Peter, MN USA Message-ID: <GUENTHER.95Sep13013822@lunen.gac.edu> References: <42nsuq$bon@elf.bsdi.com> <1995Sep11.221423.6651@forte.com> NNTP-Posting-Host: guenther@lunen.gac.edu In-reply-to: mikes@forte.com's message of Mon, 11 Sep 1995 22:14:23 GMT