mirror of
https://github.com/dankamongmen/notcurses.git
synced 2024-11-16 00:13:00 +00:00
get_tty_fd: only print fd on success
This commit is contained in:
parent
a9fd1542e4
commit
5fe3a30580
12
src/lib/fd.c
12
src/lib/fd.c
@ -457,12 +457,12 @@ int get_tty_fd(FILE* ttyfp){
|
||||
int fd = -1;
|
||||
if(ttyfp){
|
||||
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{
|
||||
if(tty_check(fd)){
|
||||
fd = dup(fd);
|
||||
}else{
|
||||
loginfo("fd %d not a TTY\n", fd);
|
||||
loginfo("fd %d is not a TTY\n", fd);
|
||||
fd = -1;
|
||||
}
|
||||
}
|
||||
@ -470,15 +470,17 @@ int get_tty_fd(FILE* ttyfp){
|
||||
if(fd < 0){
|
||||
fd = open("/dev/tty", O_RDWR | O_CLOEXEC | O_NOCTTY);
|
||||
if(fd < 0){
|
||||
loginfo("Error opening /dev/tty (%s)\n", strerror(errno));
|
||||
loginfo("couldn't open /dev/tty (%s)\n", strerror(errno));
|
||||
}else{
|
||||
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);
|
||||
fd = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
loginfo("Returning TTY fd %d\n", fd);
|
||||
if(fd >= 0){
|
||||
loginfo("returning TTY fd %d\n", fd);
|
||||
}
|
||||
return fd;
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ static void
|
||||
get_default_geometry(tinfo* ti){
|
||||
ti->default_rows = get_default_dimension("LINES", "lines", 24);
|
||||
ti->default_cols = get_default_dimension("COLUMNS", "cols", 80);
|
||||
loginfo("Default geometry: %d row%s, %d column%s\n",
|
||||
loginfo("default geometry: %d row%s, %d column%s\n",
|
||||
ti->default_rows, ti->default_rows != 1 ? "s" : "",
|
||||
ti->default_cols, ti->default_cols != 1 ? "s" : "");
|
||||
ti->dimy = ti->default_rows;
|
||||
|
Loading…
Reference in New Issue
Block a user