summaryrefslogblamecommitdiff
path: root/src/unistd/isatty.c
blob: bc220c003b241a5f6bdcf5ede417e0eb6c374209 (plain) (tree)
1
2
3
4
5
6
7
8
9
                   
                  
                      
                    
                    


                  
                           



                                                                   
 
#include <unistd.h>
#include <errno.h>
#include <sys/ioctl.h>
#include <termios.h>
#include "syscall.h"

int isatty(int fd)
{
	struct winsize wsz;
	unsigned long r = syscall(SYS_ioctl, fd, TIOCGWINSZ, &wsz);
	if (r == 0) return 1;
	if (errno != EBADF) errno = ENOTTY;
	return 0;
}