mlibc: Add isatty.

* lib/libc.c (isatty): New function.
* include/unistd.h: Declare it.
This commit is contained in:
Jan Nieuwenhuizen 2018-04-22 11:47:44 +02:00
parent 979406f3a6
commit ece39a9a18
No known key found for this signature in database
GPG Key ID: F3C1A0D9C1D65273
2 changed files with 9 additions and 0 deletions

View File

@ -51,6 +51,7 @@ int access (char const *s, int mode);
int close (int fd);
int execvp (char const *file, char *const argv[]);
char *getcwd (char *buf, size_t size);
int isatty (int fd);
off_t lseek (int fd, off_t offset, int whence);
int read (int fd, void* buf, size_t n);
int unlink (char const *file_name);

View File

@ -18,6 +18,7 @@
* along with Mes. If not, see <http://www.gnu.org/licenses/>.
*/
#include <sys/ioctl.h>
#include <stdarg.h>
#include <stdlib.h>
@ -419,4 +420,11 @@ sprintf (char *str, char const* format, ...)
va_end (ap);
return r;
}
int
isatty (int fd)
{
return ioctl (fd, TCGETS, 0) == -14; // MAGIC
}
#endif //!POSIX