tree-wide: use isatty_safe() more

This commit is contained in:
Lennart Poettering
2024-08-20 11:11:53 +02:00
parent aae47bf7a3
commit 300b7e7620
19 changed files with 36 additions and 32 deletions
+2 -2
View File
@@ -1052,8 +1052,8 @@ bool on_tty(void) {
if (cached_on_tty < 0)
cached_on_tty =
isatty(STDOUT_FILENO) > 0 &&
isatty(STDERR_FILENO) > 0;
isatty_safe(STDOUT_FILENO) &&
isatty_safe(STDERR_FILENO);
return cached_on_tty;
}
+2 -1
View File
@@ -27,6 +27,7 @@
#include "random-util.h"
#include "string-util.h"
#include "strv.h"
#include "terminal-util.h"
#include "user-util.h"
#include "utf8.h"
@@ -120,7 +121,7 @@ char* getlogname_malloc(void) {
uid_t uid;
struct stat st;
if (isatty(STDIN_FILENO) && fstat(STDIN_FILENO, &st) >= 0)
if (isatty_safe(STDIN_FILENO) && fstat(STDIN_FILENO, &st) >= 0)
uid = st.st_uid;
else
uid = getuid();