target/semihosting: Capture errno in SEMIHOSTING_SYS_ISTTY
authorJan Matyas <matyas@codasip.com>
Fri, 4 Jun 2021 09:41:36 +0000 (11:41 +0200)
committerAntonio Borneo <borneo.antonio@gmail.com>
Sat, 10 Jul 2021 14:28:42 +0000 (15:28 +0100)
Capture the value of "errno" in semihosting isatty() call,
as is done in other syscalls.

Change-Id: I41b72175635f06c000536f583e3efa30fb57379e
Signed-off-by: Jan Matyas <matyas@codasip.com>
Reviewed-on: http://openocd.zylin.com/6292
Tested-by: jenkins
Reviewed-by: Tim Newsome <tim@sifive.com>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
src/target/semihosting_common.c

index 61a69d1bd14a4bcf3d209cb70804390379e06783..bfb1ecaa7981b30fa3637dd1adda91ec77166264 100644 (file)
@@ -615,6 +615,7 @@ int semihosting_common(struct target *target)
                                        return retval;
                                int fd = semihosting_get_field(target, 0, fields);
                                semihosting->result = isatty(fd);
+                               semihosting->sys_errno = errno;
                                LOG_DEBUG("isatty(%d)=%d", fd, (int)semihosting->result);
                        }
                        break;