This is an automated email from the ASF dual-hosted git repository.

acassis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit 60ac52c4b9105422638dfacab20fc8f8486832c1
Author: chenzihan1 <[email protected]>
AuthorDate: Wed Aug 20 22:13:30 2025 +0800

    sim_hostuart.c: add nonblock flags for /dev/console
    
    to avoid the blocking indefinitely when the host
    uart is not ready to read/write data.
    
    Signed-off-by: chenzihan1 <[email protected]>
---
 arch/sim/src/sim/posix/sim_hostuart.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/arch/sim/src/sim/posix/sim_hostuart.c 
b/arch/sim/src/sim/posix/sim_hostuart.c
index 04254bc8828..4976aadd902 100644
--- a/arch/sim/src/sim/posix/sim_hostuart.c
+++ b/arch/sim/src/sim/posix/sim_hostuart.c
@@ -95,6 +95,8 @@ static void restoremode(void)
 
 void host_uart_start(void)
 {
+  int flags;
+
   /* Get the current stdin terminal mode */
 
   tcgetattr(0, &g_cooked);
@@ -103,6 +105,12 @@ void host_uart_start(void)
 
   setrawmode(0);
 
+  flags = host_uninterruptible(fcntl, 0, F_GETFL, 0);
+  if (flags > 0)
+    {
+      host_uninterruptible_no_return(fcntl, 0, F_SETFL, flags | O_NONBLOCK);
+    }
+
   /* Restore the original terminal mode before exit */
 
   atexit(restoremode);

Reply via email to