Change isatty() emulation to (incomplete) TIOCGETP emulation, so sh displays $
authorNick Downing <downing.nick@gmail.com>
Mon, 30 Jan 2017 07:56:32 +0000 (18:56 +1100)
committerNick Downing <downing.nick@gmail.com>
Mon, 30 Jan 2017 07:56:32 +0000 (18:56 +1100)
include/stdio.h
lib/libc/linux/sys/Makefile
lib/libc/linux/sys/ioctl.c
lib/libc/linux/sys/isatty.c [deleted file]

index a61197e..fe550b1 100644 (file)
@@ -92,7 +92,7 @@ extern        struct  _iobuf {
 /*int clearerr __P((register FILE *iop));*/
 
 /* stdio/doprnt.c */
-int _doprnt __P((u_char *fmt0, va_list argp, register FILE *fp));
+int _doprnt __P((char *fmt, va_list argp, register FILE *fp));
 
 /* stdio/doscan.c */
 int _doscan __P((FILE *iop, register char *fmt, register va_list argp));
index 5250aa6..6f1e8eb 100644 (file)
@@ -10,14 +10,14 @@ LD=ld
 SRCS=  chmod.c chown.c close.c dup2.c dup.c _exit.c fchmod.c fchown.c \
        fstat.c ftruncate.c getdtablesize.c getegid.c geteuid.c getgid.c \
        getpagesize.c getpgrp.c getpid.c getppid.c gettimeofday.c getuid.c \
-       ioctl.c isatty.c link.c linux.c lseek.c lstat.c read.c readv.c sbrk.c \
+       ioctl.c link.c linux.c lseek.c lstat.c read.c readv.c sbrk.c \
        setpgrp.c setregid.c setreuid.c settimeofday.c sigvec.c stat.c \
        symlink.c sync.c truncate.c umask.c unlink.c vopen.c write.c writev.c
 
 OBJS=  chmod.o chown.o close.o dup2.o dup.o _exit.o fchmod.o fchown.o \
        fstat.o ftruncate.o getdtablesize.o getegid.o geteuid.o getgid.o \
        getpagesize.o getpgrp.o getpid.o getppid.o gettimeofday.o getuid.o \
-       ioctl.o isatty.o link.o linux.o lseek.o lstat.o read.o readv.o sbrk.o \
+       ioctl.o link.o linux.o lseek.o lstat.o read.o readv.o sbrk.o \
        setpgrp.o setregid.o setreuid.o settimeofday.o sigvec.o stat.o \
        symlink.o sync.o truncate.o umask.o unlink.o vopen.o write.o writev.o
 TAGSFILE=tags
index 81fd9ea..c0e825c 100644 (file)
@@ -1,7 +1,9 @@
 #include <nox_errno.h>
 #include <sys/nox_ioctl.h>
 #include <sys/nox_types.h>
+#include <nox_unistd.h>
 
+#include <string.h>
 #include <sys/errno.h>
 #include <sys/ioctl.h>
 #include <sys/types.h>
@@ -9,6 +11,14 @@
 
 int ioctl(d, r, p) int d; u_long r; void *p; {
        switch (r) {
+       case TIOCGETP:
+               if (!nox_isatty((nox_int)d)) {
+                       errno = ENOTTY;
+                       return -1;
+               }
+               /* just fake success for now */
+               bzero(p, sizeof(struct sgttyb));
+               return 0;
        case TIOCGWINSZ: {
                struct nox_winsize ws;
                if (nox_ioctl((nox_int)d, nox_TIOCGWINSZ, &ws)) {
diff --git a/lib/libc/linux/sys/isatty.c b/lib/libc/linux/sys/isatty.c
deleted file mode 100644 (file)
index 9eb4727..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-#include <nox_errno.h>
-#include <nox_unistd.h>
-
-#include <sys/errno.h>
-#include <sys/ioctl.h>
-#include "linux.h"
-
-int isatty(f) int f; {
-       nox_int res;
-
-       res = nox_isatty(f);
-       if (res == (nox_int)-1)
-               errno = htot_errno(nox_errno);
-       return (int)res;
-}