This is an automated email from Gerrit.

"Marek Vrbka <marek.vr...@codasip.com>" just uploaded a new patch set to 
Gerrit, which you can find at https://review.openocd.org/c/openocd/+/7725

-- gerrit

commit 168741426a68fa086fbae4b3d59a5e0eaffebdb5
Author: Marek Vrbka <marek.vr...@codasip.com>
Date:   Tue May 30 14:16:38 2023 +0200

    semihosting: fix non-zero value on Windows isatty()
    
    On Windows, isatty() can return any non-zero value if it's an interactive
    device. Which diverges from the ARM semihosting specification. This patch
    introduces a fix to make the SYS_ISTTY operation conform to spec.
    
    Change-Id: I9bc4f3cb82370812825d52419851910b3e3f35cc
    Signed-off-by: Marek Vrbka <marek.vr...@codasip.com>

diff --git a/src/target/semihosting_common.c b/src/target/semihosting_common.c
index 3ed112ba94..6c91876c73 100644
--- a/src/target/semihosting_common.c
+++ b/src/target/semihosting_common.c
@@ -779,7 +779,8 @@ int semihosting_common(struct target *target)
                                if (retval != ERROR_OK)
                                        return retval;
                                int fd = semihosting_get_field(target, 0, 
fields);
-                               semihosting->result = isatty(fd);
+                               // isatty() on Windows may return any non-zero 
value if fd is a terminal
+                               semihosting->result = isatty(fd) ? 1 : 0;
                                semihosting->sys_errno = errno;
                                LOG_DEBUG("isatty(%d)=%" PRId64, fd, 
semihosting->result);
                        }

-- 

Reply via email to