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> extern int errno; 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; }