#include <windows.h> | |
#include <shared.h> | |
#include <errno.h> | |
int isatty(int fd) { | |
BY_HANDLE_FILE_INFORMATION_NEW information; | |
if(fd == -1) { | |
errno = EBADF; | |
return 0; | |
} | |
int r = !GetFileInformationByHandle((void *)fd, (BY_HANDLE_FILE_INFORMATION *)&information); | |
if(r) { | |
if(GetLastError() != ERROR_INVALID_FUNCTION) return 0; | |
SetLastError(0); | |
} | |
return r; | |
} |