Email List: Xaustin-group-lX
[All Lists]

Re: AI 42: atexit() and dlclose()

To: "Clive D.W. Feather" <yyyyy@xxxxxxxxx>
Subject: Re: AI 42: atexit() and dlclose()
From: Dave Butenhof <yyyyyyyyyyyyyy@xxxxxxxxxx>
Date: Wed, 14 Mar 2001 09:35:46 -0500
Cc: Mark Brown <yyyyy@xxxxxxxxxx>, Austin Group <yyyyyyyyyyyyyy@xxxxxxxxxxxxx>
Organization: Compaq Computer Corporation
References: <B6D3DFD4.3655%bmark@us.ibm.com> <3AAF56DD.969EB1FD@compaq.com> <20010314130123.R83882@demon.net>
"Clive D.W. Feather" wrote:

> Dave Butenhof said:
> >> An exception is that a function is called after
> >>           any previously registered functions that had already been called
> >>           at the time it was registered.
> >
> > I don't understand the intent of this. (Yes, I see that it is a minor 
>adjustment to
> > a previous addition to XSH6, which I apparently missed entirely.) Anyone 
>know if
> > this is supposed to refer to the behavior of exit handlers declared within 
>exit
> > handlers?
>
> Yes, and it's there for C99 consistency.
>
>     main () { ... atexit (handler_a); ... }
>
>     handler_a () { ... atexit (handler_b); ... }
>
> Without this wording the requirement is that handler_b is called before
> handler_a, which is obviously nonsense. It's also been interpreted by
> people as requiring handler_b to be called within the atexit call. This
> wording makes it clear that handler_b is called as soon as handler_a exits.
>
> > The change history provides no explanation. (The only
> > justified changes are for alignment with C99, and this text does not come 
>from
> > C99.)
>
> Yes it does: 7.20.4.3 paragraph 3:
>
>     "except that  a  function  is  called  after  any  previously
>     registered  functions  that  had  already been called at the
>     time it was registered"

Ah; it's under exit() rather than atexit(). The same text is in the XSH6 
description of
exit(), so there would seem to be no reason to duplicate it in atexit(). I also 
think
that the context in exit() makes the statement more clear. (An example would be 
even
better.)

/------------------[ yyyyyyyyyyyyyy@xxxxxxxxxx ]------------------\
| Compaq Computer Corporation              POSIX Thread Architect |
|     My book: http://www.awl.com/cseng/titles/0-201-63392-2/     |
\-----[ http://home.earthlink.net/~anneart/family/dave.html ]-----/

<Prev in Thread] Current Thread [Next in Thread>