[rtems commit] Use atexit() handler to close std file descriptors
Sebastian Huber
sebh at rtems.org
Wed Feb 3 09:35:06 UTC 2016
Module: rtems
Branch: master
Commit: f64c6b4c492bd4f4efe32ec69e9f4c69bf45be88
Changeset: http://git.rtems.org/rtems/commit/?id=f64c6b4c492bd4f4efe32ec69e9f4c69bf45be88
Author: Sebastian Huber <sebastian.huber at embedded-brains.de>
Date: Mon Jan 25 21:23:53 2016 +0100
Use atexit() handler to close std file descriptors
---
cpukit/libcsupport/include/rtems/libio.h | 2 --
cpukit/libcsupport/src/newlibc_exit.c | 3 ---
cpukit/libcsupport/src/open_dev_console.c | 3 +++
cpukit/sapi/include/confdefs.h | 7 -------
4 files changed, 3 insertions(+), 12 deletions(-)
diff --git a/cpukit/libcsupport/include/rtems/libio.h b/cpukit/libcsupport/include/rtems/libio.h
index 28b4627..824fa28 100644
--- a/cpukit/libcsupport/include/rtems/libio.h
+++ b/cpukit/libcsupport/include/rtems/libio.h
@@ -1487,8 +1487,6 @@ extern const rtems_libio_helper rtems_libio_init_helper;
extern const rtems_libio_helper rtems_libio_post_driver_helper;
-extern const rtems_libio_helper rtems_libio_exit_helper;
-
void rtems_libio_helper_null(void);
void rtems_libio_post_driver(void);
diff --git a/cpukit/libcsupport/src/newlibc_exit.c b/cpukit/libcsupport/src/newlibc_exit.c
index c093bb2..53f97b0 100644
--- a/cpukit/libcsupport/src/newlibc_exit.c
+++ b/cpukit/libcsupport/src/newlibc_exit.c
@@ -14,8 +14,6 @@
#include <rtems.h>
#if defined(RTEMS_NEWLIB)
-#include <rtems/libio.h>
-
#include <stdio.h>
#include <unistd.h>
@@ -41,7 +39,6 @@ void _exit(int status)
FINI_SYMBOL();
#endif
- (*rtems_libio_exit_helper)();
rtems_shutdown_executive(status);
/* does not return */
}
diff --git a/cpukit/libcsupport/src/open_dev_console.c b/cpukit/libcsupport/src/open_dev_console.c
index 6617a78..2e111cc 100644
--- a/cpukit/libcsupport/src/open_dev_console.c
+++ b/cpukit/libcsupport/src/open_dev_console.c
@@ -16,6 +16,7 @@
#include <rtems.h>
#include <rtems/libio.h>
#include <fcntl.h>
+#include <stdlib.h>
/*
* This is a replaceable stub which opens the console, if present.
@@ -45,5 +46,7 @@ void rtems_libio_post_driver(void)
if ((stderr_fd = open("/dev/console", O_WRONLY, 0)) == -1)
rtems_fatal_error_occurred( 0x55544432 ); /* error STD2 */
+
+ atexit(rtems_libio_exit);
}
diff --git a/cpukit/sapi/include/confdefs.h b/cpukit/sapi/include/confdefs.h
index 2c108ba..6761674 100644
--- a/cpukit/sapi/include/confdefs.h
+++ b/cpukit/sapi/include/confdefs.h
@@ -129,13 +129,6 @@ const rtems_libio_helper rtems_libio_post_driver_helper =
rtems_libio_post_driver;
#endif
-const rtems_libio_helper rtems_libio_exit_helper =
- #ifdef CONFIGURE_APPLICATION_DISABLE_FILESYSTEM
- rtems_libio_helper_null;
- #else
- rtems_libio_exit;
- #endif
-
#ifndef CONFIGURE_APPLICATION_DISABLE_FILESYSTEM
RTEMS_SYSINIT_ITEM(
rtems_filesystem_initialize,
More information about the vc
mailing list