You need to sign in or sign up before continuing.
isatty.c 281 字节
Newer Older
R
Rich Felker 已提交
1
#include <unistd.h>
2
#include <errno.h>
3
#include <sys/ioctl.h>
4
#include <termios.h>
5
#include "syscall.h"
R
Rich Felker 已提交
6 7 8

int isatty(int fd)
{
9
	struct winsize wsz;
10 11 12 13
	unsigned long r = syscall(SYS_ioctl, fd, TIOCGWINSZ, &wsz);
	if (r == 0) return 1;
	if (errno != EBADF) errno = ENOTTY;
	return 0;
R
Rich Felker 已提交
14
}