summaryrefslogtreecommitdiffstats
path: root/mdk-stage1/dietlibc/lib/isatty.c
blob: 4858a364d92f889b19e5b205c0dee5ecd0a2864e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#define ioctl libc_ioctl
#include <termios.h>
#undef ioctl
#include <sys/ioctl.h>
#include <errno.h>
#include <unistd.h>
#include "dietfeatures.h"

int isatty(int fd) {
  int save;
  int is_tty;
  struct termios term;

  save = errno;
  is_tty = ioctl(fd, TCGETS, &term) == 0;
  errno = save;

  return is_tty;
}