From f6dc6f68759df560217051a3c276d0b57f20ff02 Mon Sep 17 00:00:00 2001 From: George Koehler Date: Tue, 20 Sep 2016 21:28:37 -0400 Subject: [PATCH] Implement isatty() for Linux. If it understands TIOCGETD, then it is a tty, else it isn't one. This seems to help Basic's input statement so I can see the prompt before I enter my input. --- plat/linux/libsys/ioctl.c | 11 +++++++++++ plat/linux/libsys/isatty.c | 15 +++++++-------- 2 files changed, 18 insertions(+), 8 deletions(-) create mode 100644 plat/linux/libsys/ioctl.c diff --git a/plat/linux/libsys/ioctl.c b/plat/linux/libsys/ioctl.c new file mode 100644 index 000000000..a77d1f49f --- /dev/null +++ b/plat/linux/libsys/ioctl.c @@ -0,0 +1,11 @@ +#include "libsys.h" + +/* + * The usual prototype is ioctl(int, unsigned long, ...). We use a + * different prototype to easily get argp, and we don't include any + * header file that would declare the usual prototype. + */ +int ioctl(int fd, unsigned long request, void *argp) +{ + return _syscall(__NR_ioctl, fd, request, argp); +} diff --git a/plat/linux/libsys/isatty.c b/plat/linux/libsys/isatty.c index a35a8c0a8..655f40569 100644 --- a/plat/linux/libsys/isatty.c +++ b/plat/linux/libsys/isatty.c @@ -1,13 +1,12 @@ -/* $Source: /cvsroot/tack/Ack/plat/linux386/libsys/isatty.c,v $ - * $State: Exp $ - * $Revision: 1.1 $ +/* + * XXX - can't #include because libcc.ansi and libsys + * both provide it, and we might find the wrong one. */ - -#include -#include -#include +#define TIOCGETD 0x5424 +int ioctl(int fd, unsigned long, ...); int isatty(int fd) { - return 0; + int line_disc; + return 0 <= ioctl(fd, TIOCGETD, &line_disc); } -- 2.34.1