diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2016-12-09 09:18:57 +0100 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2016-12-12 08:03:30 +0100 |
commit | af8ced5e2d8fb8552f29a1bad5a32a72b939adc7 (patch) | |
tree | 5e746c43582543ec7d370e4eb07f965c6397f993 /cpukit/libcsupport/src/open_dev_console.c | |
parent | Add INTERNAL_ERROR_LIBIO_SEM_CREATE_FAILED (diff) | |
download | rtems-af8ced5e2d8fb8552f29a1bad5a32a72b939adc7.tar.bz2 |
libio: Ensure proper std file descriptors
Diffstat (limited to 'cpukit/libcsupport/src/open_dev_console.c')
-rw-r--r-- | cpukit/libcsupport/src/open_dev_console.c | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/cpukit/libcsupport/src/open_dev_console.c b/cpukit/libcsupport/src/open_dev_console.c index 2e111ccf3a..14257e8d29 100644 --- a/cpukit/libcsupport/src/open_dev_console.c +++ b/cpukit/libcsupport/src/open_dev_console.c @@ -17,20 +17,17 @@ #include <rtems/libio.h> #include <fcntl.h> #include <stdlib.h> +#include <unistd.h> /* * This is a replaceable stub which opens the console, if present. */ void rtems_libio_post_driver(void) { - int stdin_fd; - int stdout_fd; - int stderr_fd; - /* * Attempt to open /dev/console. */ - if ((stdin_fd = open("/dev/console", O_RDONLY, 0)) == -1) { + if (open("/dev/console", O_RDONLY, 0) != STDIN_FILENO) { /* * There may not be a console driver so this is OK. */ @@ -41,11 +38,13 @@ void rtems_libio_post_driver(void) * But if we find /dev/console once, we better find it twice more * or something is REALLY wrong. */ - if ((stdout_fd = open("/dev/console", O_WRONLY, 0)) == -1) - rtems_fatal_error_occurred( 0x55544431 ); /* error STD1 */ + if (open("/dev/console", O_WRONLY, 0) != STDOUT_FILENO) { + rtems_fatal_error_occurred( 0x55544431 ); + } - if ((stderr_fd = open("/dev/console", O_WRONLY, 0)) == -1) - rtems_fatal_error_occurred( 0x55544432 ); /* error STD2 */ + if (open("/dev/console", O_WRONLY, 0) != STDERR_FILENO) { + rtems_fatal_error_occurred( 0x55544432 ); + } atexit(rtems_libio_exit); } |