[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Minios-devel] [UNIKRAFT/NEWLIB PATCH v2 5/5] Implement isatty



Signed-off-by: Vlad-Andrei Badoiu <vlad_andrei.badoiu@xxxxxxxxxxxxxxx>
---
 console.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/console.c b/console.c
index 7016957..bf9cfe8 100644
--- a/console.c
+++ b/console.c
@@ -35,11 +35,23 @@
  * THIS HEADER MAY NOT BE EXTRACTED OR MODIFIED IN ANY WAY.
  */
 
+#include <errno.h>
+#include <sys/stat.h>
 #include <uk/essentials.h>
 
-int isatty(int file __unused)
+int isatty(int fd)
 {
-       return 1;
+       struct stat buf;
+
+       if (fstat(fd, &buf) < 0) {
+               errno = EBADF;
+               return 0;
+       }
+       if (S_ISCHR(buf.st_mode))
+               return 1;
+
+       errno = ENOTTY;
+       return 0;
 }
 
 char *ttyname(int fd __unused)
-- 
2.21.0

_______________________________________________
Minios-devel mailing list
Minios-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/minios-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.