Fix tty ioctl test for non-tty stdout

This commit is contained in:
Hui, Chunyang 2020-04-13 04:25:25 +00:00
parent 0ffc127bff
commit 7372d0277c

@ -17,8 +17,14 @@
int test_tty_ioctl_TIOCGWINSZ(void) {
struct winsize winsize;
if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &winsize) < 0) {
THROW_ERROR("failed to ioctl TIOCGWINSZ");
if (isatty(STDOUT_FILENO)) {
if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &winsize) < 0) {
THROW_ERROR("failed to ioctl TIOCGWINSZ");
}
} else {
// FIXME: /dev/tty should be opened. But it has not been implemented in Occlum yet.
// So we just skip this test if STDOUT is redirected.
printf("Warning: test_tty_ioctl_TIOCGWINSZ is skipped\n");
}
return 0;
}