Windows: introduce tty_check() wrapper for isatty() #2098

pull/2122/head
nick black 3 years ago
parent 2732620821
commit 8097b937c0

@ -472,7 +472,7 @@ int get_tty_fd(FILE* ttyfp){
if((fd = fileno(ttyfp)) < 0){ if((fd = fileno(ttyfp)) < 0){
logwarn("No file descriptor was available in outfp %p\n", ttyfp); logwarn("No file descriptor was available in outfp %p\n", ttyfp);
}else{ }else{
if(isatty(fd)){ if(tty_check(fd)){
fd = dup(fd); fd = dup(fd);
}else{ }else{
loginfo("fd %d not a TTY\n", fd); loginfo("fd %d not a TTY\n", fd);
@ -485,7 +485,7 @@ int get_tty_fd(FILE* ttyfp){
if(fd < 0){ if(fd < 0){
loginfo("Error opening /dev/tty (%s)\n", strerror(errno)); loginfo("Error opening /dev/tty (%s)\n", strerror(errno));
}else{ }else{
if(!isatty(fd)){ if(!tty_check(fd)){
loginfo("File descriptor for /dev/tty (%d) is not actually a TTY\n", fd); loginfo("File descriptor for /dev/tty (%d) is not actually a TTY\n", fd);
close(fd); close(fd);
fd = -1; fd = -1;

Loading…
Cancel
Save