[uClibc]atexit() and __stdio_close_all

Michael Shmulevich michaels at jungo.com
Sun May 6 09:17:18 UTC 2001


Hi all,

Wile looking at __uClibc_main.c I realised that we are overkilling the 
__uclibc_cleanup without any such need: why don't we just register a 
__stdio_close_all as an atexit() handler and this will do all the job?
Like this:

Index: misc/internals/__uClibc_main.c
===================================================================
RCS file: /arch/cvs/rg/pkg/ulibc/misc/internals/__uClibc_main.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -b -u -B -r1.2 -r1.3
--- misc/internals/__uClibc_main.c      2001/04/18 14:19:11     1.2
+++ misc/internals/__uClibc_main.c      2001/05/06 09:20:11     1.3
@@ -40,7 +40,7 @@
  extern void __stdio_close_all(void);

  typedef void (*vfuncp) (void);
-vfuncp __uClibc_cleanup = __stdio_close_all;
+vfuncp __uClibc_cleanup;

  /*
   * Now for our main routine.
@@ -65,6 +65,9 @@
          * we call main.
          */
         __set_errno(0);
+
+       /* Regiter __stdio_close_all a first exit handler */
+       atexit(__stdio_close_all);

         /*
          * Finally, invoke application's main and then exit.
Index: stdlib/atexit.c
===================================================================
RCS file: /arch/cvs/rg/pkg/ulibc/stdlib/atexit.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -b -u -B -r1.2 -r1.3
--- stdlib/atexit.c     2001/04/18 14:19:11     1.2
+++ stdlib/atexit.c     2001/05/06 09:20:11     1.3
@@ -45,7 +45,6 @@
         for (count = __atexit_count ; count-- ; ) {
                 (*__atexit_table[count])();
         }
-       __stdio_close_all();
  }

  int atexit(vfuncp ptr)

-- 
Sincerely yours,
Michael Shmulevich
______________________________________
Software Developer
Jungo - R&D
email: michaels at jungo.com
web: http://www.jungo.com
Phone: 1-877-514-0537(USA)  +972-9-8859365(Worldwide) ext. 233
Fax:   1-877-514-0538(USA)  +972-9-8859366(Worldwide)






More information about the uClibc mailing list