[fusl] Don't syscall(SYS_ioctl, ...) in stdio
This previously inlined the definition of isatty, which asks for the
window size via an ioctl call. Instead, use isatty.
R=viettrungluu@chromium.org
Review URL: https://codereview.chromium.org/1717003002 .
diff --git a/fusl/src/stdio/__fdopen.c b/fusl/src/stdio/__fdopen.c
index 3a62f30..eb72928 100644
--- a/fusl/src/stdio/__fdopen.c
+++ b/fusl/src/stdio/__fdopen.c
@@ -1,13 +1,12 @@
#include "stdio_impl.h"
#include <stdlib.h>
-#include <sys/ioctl.h>
#include <fcntl.h>
#include <errno.h>
#include <string.h>
+#include <unistd.h>
FILE* __fdopen(int fd, const char* mode) {
FILE* f;
- struct winsize wsz;
/* Check for valid initial mode character */
if (!strchr("rwa", *mode)) {
@@ -44,7 +43,7 @@
/* Activate line buffered mode for terminals */
f->lbf = EOF;
- if (!(f->flags & F_NOWR) && !__syscall(SYS_ioctl, fd, TIOCGWINSZ, &wsz))
+ if (!(f->flags & F_NOWR) && isatty(fd))
f->lbf = '\n';
/* Initialize op ptrs. No problem if some are unneeded. */
diff --git a/fusl/src/stdio/__stdout_write.c b/fusl/src/stdio/__stdout_write.c
index f17b9a5..5cbe779 100644
--- a/fusl/src/stdio/__stdout_write.c
+++ b/fusl/src/stdio/__stdout_write.c
@@ -1,10 +1,9 @@
#include "stdio_impl.h"
-#include <sys/ioctl.h>
+#include <unistd.h>
size_t __stdout_write(FILE* f, const unsigned char* buf, size_t len) {
- struct winsize wsz;
f->write = __stdio_write;
- if (!(f->flags & F_SVB) && __syscall(SYS_ioctl, f->fd, TIOCGWINSZ, &wsz))
+ if (!(f->flags & F_SVB) && !isatty(f->fd))
f->lbf = -1;
return __stdio_write(f, buf, len);
}