summaryrefslogtreecommitdiffstats
path: root/lib/libc/gen/isatty.c
diff options
context:
space:
mode:
authorderaadt <deraadt@openbsd.org>2015-05-17 01:22:01 +0000
committerderaadt <deraadt@openbsd.org>2015-05-17 01:22:01 +0000
commit96384aa4ffd2be9256cc74ce93d4c06cd907c7a9 (patch)
tree9c5f7b92840fc859fff6452b9049acb9e2a492f6 /lib/libc/gen/isatty.c
parentUse fcntl() to set non-blocking-mode, rather ioctl(). This has a better (diff)
downloadwireguard-openbsd-96384aa4ffd2be9256cc74ce93d4c06cd907c7a9.tar.xz
wireguard-openbsd-96384aa4ffd2be9256cc74ce93d4c06cd907c7a9.zip
isatty() is used by stdio to determine the buffering mode. Add a F_ISATTY
option to fcntl(), so that isatty() can use this rather than than the bloated ioctl() interface. Reducing uses of ioctl() by libc makes it easier to constrain programs with various kinds of systrace sandboxes. ok guenther, previously discussed as a concept with nicm
Diffstat (limited to 'lib/libc/gen/isatty.c')
-rw-r--r--lib/libc/gen/isatty.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/lib/libc/gen/isatty.c b/lib/libc/gen/isatty.c
index 0a94648a29f..3b63f2575c4 100644
--- a/lib/libc/gen/isatty.c
+++ b/lib/libc/gen/isatty.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: isatty.c,v 1.8 2013/04/17 17:40:35 tedu Exp $ */
+/* $OpenBSD: isatty.c,v 1.9 2015/05/17 01:22:01 deraadt Exp $ */
/*
* Copyright (c) 1988, 1993
* The Regents of the University of California. All rights reserved.
@@ -28,13 +28,10 @@
* SUCH DAMAGE.
*/
-#include <termios.h>
-#include <unistd.h>
+#include <fcntl.h>
int
isatty(int fd)
{
- struct termios t;
-
- return (tcgetattr(fd, &t) != -1);
+ return (fcntl(fd, F_ISATTY));
}