-/* $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.
* 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));
}
-/* $OpenBSD: kern_descrip.c,v 1.119 2015/04/30 21:18:45 millert Exp $ */
+/* $OpenBSD: kern_descrip.c,v 1.120 2015/05/17 01:22:01 deraadt Exp $ */
/* $NetBSD: kern_descrip.c,v 1.42 1996/03/30 22:24:38 christos Exp $ */
/*
*retval = OFLAGS(fp->f_flag);
break;
+ case F_ISATTY:
+ vp = (struct vnode *)fp->f_data;
+ if (fp->f_type == DTYPE_VNODE && (vp->v_flag & VISTTY))
+ *retval = 1;
+ else {
+ *retval = 0;
+ error = ENOTTY;
+ }
+ break;
+
case F_SETFL:
fp->f_flag &= ~FCNTLFLAGS;
fp->f_flag |= FFLAGS((long)SCARG(uap, arg)) & FCNTLFLAGS;
-/* $OpenBSD: fcntl.h,v 1.20 2013/06/05 01:26:00 guenther Exp $ */
+/* $OpenBSD: fcntl.h,v 1.21 2015/05/17 01:22:01 deraadt Exp $ */
/* $NetBSD: fcntl.h,v 1.8 1995/03/26 20:24:12 jtc Exp $ */
/*-
#if __POSIX_VISIBLE >= 200809
#define F_DUPFD_CLOEXEC 10 /* duplicate with FD_CLOEXEC set */
#endif
+#if __BSD_VISIBLE
+#define F_ISATTY 11 /* used by isatty(3) */
+#endif
/* file descriptor flags (F_GETFD, F_SETFD) */
#define FD_CLOEXEC 1 /* close-on-exec flag */
#!/bin/sh
-# $OpenBSD: mksubr,v 1.27 2015/04/17 06:14:36 guenther Exp $
+# $OpenBSD: mksubr,v 1.28 2015/05/17 01:22:01 deraadt Exp $
#
# Copyright (c) 2006 David Kirchner <dpk@dpk.net>
#
} else if (arg1 == F_SETFL) {
(void)putchar(',');
doflagsname(arg, 0);
- } else if (!fancy || (arg1 != F_GETFD && arg1 != F_GETFL))
+ } else if (!fancy || (arg1 != F_GETFD && arg1 != F_GETFL && arg1 != F_ISATTY))
(void)printf(",%#x", arg);
}