diff --git a/hal/common/retarget.cpp b/hal/common/retarget.cpp index c42190fbc4..004f615022 100644 --- a/hal/common/retarget.cpp +++ b/hal/common/retarget.cpp @@ -609,9 +609,11 @@ extern "C" void exit(int return_code) { #endif #if DEVICE_STDIO_MESSAGES +#if MBED_CONF_CORE_STDIO_FLUSH_AT_EXIT fflush(stdout); fflush(stderr); #endif +#endif #if DEVICE_SEMIHOST if (mbed_interface_connected()) { diff --git a/mbed_lib.json b/mbed_lib.json index 6300a4b0f2..e524af3ddc 100644 --- a/mbed_lib.json +++ b/mbed_lib.json @@ -9,6 +9,11 @@ "stdio-baud-rate": { "help": "Baud rate for stdio", "value": 9600 + }, + + "stdio-flush-at-exit": { + "help": "Enable or disable the flush of standard I/O's at exit.", + "value": true } } }