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.vrbka@codasip.com> Reviewed-on: https://review.openocd.org/c/openocd/+/7725 Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com> Tested-by: jenkins Reviewed-by: Jan Matyas <jan.matyas@codasip.com>
This commit is contained in:
parent
71180e6753
commit
9f23a1d7c1
|
@ -779,7 +779,8 @@ int semihosting_common(struct target *target)
|
||||||
if (retval != ERROR_OK)
|
if (retval != ERROR_OK)
|
||||||
return retval;
|
return retval;
|
||||||
int fd = semihosting_get_field(target, 0, fields);
|
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;
|
semihosting->sys_errno = errno;
|
||||||
LOG_DEBUG("isatty(%d)=%" PRId64, fd, semihosting->result);
|
LOG_DEBUG("isatty(%d)=%" PRId64, fd, semihosting->result);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue