[uClibc]atexit() and __stdio_close_all

Manuel Novoa III mnovoa3 at bellsouth.net
Sun May 6 21:47:33 UTC 2001


Michael Shmulevich wrote:
> 
> > I had rewritten atexit.c before Erik got shared uClibc working, and my
> > concern at the time was being able to minimize the size of the staticly
> > linked
> > executables.   By not using atexit(__stdio_close_all), we didn't pull
> > atexit.o
> > into the executable just because we used stdio.
> 
> Still it makes a little sence to me: you could've called
> stdio_close_all() explicitly at ulibc's exit(), without all the game
> with atexit_hadler(). You always call it anyway, be it with or without
> using atexit() itself. Why using such a weird 'if' for __uClibc_cleanup?


After looking at this again, I agree that it needs to be rewritten.
Right now __uClibc_cleanup() can be called by exit() or by abort().
It shouldn't be called by abort however; at least not according to C89.
Erik, what do the latest standards say about this?  C89 says though,
that
that the flushing and closing of streams is implementation defined when
abort()ing.

As far as "weird 'if' for __uClibc_cleanup" goes, I asume you're talking
about
exit().  When the atexit_handler is called, it sets __uClibc_cleanup to
NULL
in case someone registers a function with atexit that calls exit itself.

Manuel





More information about the uClibc mailing list