source: rtems/cpukit/libcsupport/src/newlibc_exit.c @ 62aa318

4.115
Last change on this file since 62aa318 was 45c9b7d4, checked in by Sebastian Huber <sebastian.huber@…>, on 04/23/13 at 13:04:42

libcsupport: POSIX conformance for _exit()

According to POSIX the _exit() function shall not call functions
registered with atexit() nor any registered signal handlers.

See also tests libtests/exit01 and libtests/exit02.

Make libc_wrapup() static. Remove out of date comments. Remove
superfluous declarations, defines and includes.

  • Property mode set to 100644
File size: 1.4 KB
RevLine 
[40ff680]1/*
2 *  COPYRIGHT (c) 1994 by Division Incorporated
3 *
4 *  The license and distribution terms for this file may be
5 *  found in the file LICENSE in this distribution or at
6 *  http://www.rtems.com/license/LICENSE.
7 *
8 */
9
10#if HAVE_CONFIG_H
11#include "config.h"
12#endif
13
14#define __RTEMS_VIOLATE_KERNEL_VISIBILITY__
15#include <rtems.h>
16
17#if defined(RTEMS_NEWLIB)
18#include <rtems/libcsupport.h>
19
20#include <stdio.h>
[45c9b7d4]21#include <unistd.h>
[40ff680]22
[45c9b7d4]23static void libc_wrapup(void)
[40ff680]24{
25  /*
26   *  In case RTEMS is already down, don't do this.  It could be
27   *  dangerous.
28   */
29
30  if (!_System_state_Is_up(_System_state_Get()))
31     return;
32
33  /*
34   * Try to drain output buffers.
35   *
36   * Should this be changed to do *all* file streams?
37   *    _fwalk (_REENT, fclose);
38   */
39
40  fclose (stdin);
41  fclose (stdout);
42  fclose (stderr);
43}
44
[d6a72fff]45/* FIXME: These defines are a blatant hack */
[10ace49]46
[f73fc29]47  #if defined(__USE_INIT_FINI__)
[5365e60]48    #if defined(__m32r__)
49      #define FINI_SYMBOL __fini
[1f3585d1]50    #elif defined(__ARM_EABI__)
51      #define FINI_SYMBOL __libc_fini_array
[5365e60]52    #else
53      #define FINI_SYMBOL _fini
54    #endif
[18daff9]55
[5365e60]56    extern void FINI_SYMBOL( void );
[f73fc29]57  #endif
[83734c9d]58
[45c9b7d4]59void _exit(int status)
[40ff680]60{
[393a861d]61  /*
[18daff9]62   *  If the toolset uses init/fini sections, then we need to
[393a861d]63   *  run the global destructors now.
64   */
[1f3585d1]65  #if defined(FINI_SYMBOL)
[5365e60]66    FINI_SYMBOL();
[393a861d]67  #endif
[83734c9d]68
[40ff680]69  libc_wrapup();
70  rtems_shutdown_executive(status);
71  for (;;) ; /* to avoid warnings */
72}
73
74#endif
Note: See TracBrowser for help on using the repository browser.