diff --git a/cpukit/include/rtems/score/interr.h b/cpukit/include/rtems/score/interr.h index 2fcf241607..f05238f5bb 100644 --- a/cpukit/include/rtems/score/interr.h +++ b/cpukit/include/rtems/score/interr.h @@ -232,7 +232,8 @@ typedef enum { INTERNAL_ERROR_IDLE_THREAD_CREATE_FAILED = 43, INTERNAL_ERROR_NO_MEMORY_FOR_IDLE_TASK_STORAGE = 44, INTERNAL_ERROR_IDLE_THREAD_STACK_TOO_SMALL = 45, - INTERNAL_ERROR_CANNOT_DISABLE_DATA_CACHE = 46 + INTERNAL_ERROR_CANNOT_DISABLE_DATA_CACHE = 46, + INTERNAL_ERROR_LIBIO_STDIN_FD_OPEN_FAILED = 47, } Internal_errors_Core_list; typedef CPU_Uint32ptr Internal_errors_t; diff --git a/cpukit/libcsupport/src/open_dev_console.c b/cpukit/libcsupport/src/open_dev_console.c index e5f34068fe..23d8927f54 100644 --- a/cpukit/libcsupport/src/open_dev_console.c +++ b/cpukit/libcsupport/src/open_dev_console.c @@ -47,14 +47,22 @@ */ void rtems_libio_post_driver(void) { + int fd = 0; /* * Attempt to open /dev/console. */ - if ( open( CONSOLE_DEVICE_NAME, O_RDONLY, 0 ) != STDIN_FILENO ) { + if ( ( fd = open( CONSOLE_DEVICE_NAME, O_RDONLY, 0 ) ) != STDIN_FILENO ) { /* * There may not be a console driver so this is OK. */ - return; + if ( fd < 0 ) { + return; + } + + /* + * If open succeeds, but doesn't give us the stdin fileno we expect, bail out... + */ + _Internal_error( INTERNAL_ERROR_LIBIO_STDIN_FD_OPEN_FAILED ); } /* diff --git a/cpukit/sapi/src/interrtext.c b/cpukit/sapi/src/interrtext.c index 4150416240..874b2fdfc1 100644 --- a/cpukit/sapi/src/interrtext.c +++ b/cpukit/sapi/src/interrtext.c @@ -86,7 +86,8 @@ static const char *const internal_error_text[] = { "INTERNAL_ERROR_RTEMS_INIT_TASK_CONSTRUCT_FAILED", "INTERNAL_ERROR_IDLE_THREAD_CREATE_FAILED", "INTERNAL_ERROR_NO_MEMORY_FOR_IDLE_TASK_STORAGE", - "INTERNAL_ERROR_IDLE_THREAD_STACK_TOO_SMALL" + "INTERNAL_ERROR_IDLE_THREAD_STACK_TOO_SMALL", + "INTERNAL_ERROR_LIBIO_STDIN_FD_OPEN_FAILED" }; const char *rtems_internal_error_text( rtems_fatal_code error )