isatty.c 197 B

12345678910
  1. #include <unistd.h>
  2. #include <errno.h>
  3. #include <sys/ioctl.h>
  4. int isatty(int fd) {
  5. int dtype = ioctl(fd, IOCTLDTYPE, NULL);
  6. if (dtype == IOCTL_DTYPE_TTY) return 1;
  7. errno = EINVAL;
  8. return 0;
  9. }