summaryrefslogtreecommitdiff
path: root/src/unistd/isatty.c
blob: 21222edab6ee5263de98c8504032c9f87f29fbd1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
#include <unistd.h>
#include <errno.h>
#include <sys/ioctl.h>
#include "syscall.h"

int isatty(int fd)
{
	struct winsize wsz;
	/* +1 converts from error status (0/-1) to boolean (1/0) */
	return syscall(SYS_ioctl, fd, TIOCGWINSZ, &wsz) + 1;
}