musl-tcc/src/unistd/isatty.c

14 lines
260 B
C
Raw Permalink Normal View History

2022-03-20 04:48:53 -04:00
#include <unistd.h>
#include <errno.h>
#include <sys/ioctl.h>
#include "syscall.h"
int isatty(int fd)
{
struct winsize wsz;
unsigned long r = syscall(SYS_ioctl, fd, TIOCGWINSZ, &wsz);
if (r == 0) return 1;
if (errno != EBADF) errno = ENOTTY;
return 0;
}