various: clean up isatty() handling

As per https://github.com/systemd/systemd/pull/30547#discussion_r1434371627
This commit is contained in:
Mike Yuan
2023-12-22 23:06:49 +08:00
parent 76270f5c09
commit dd9c8da865
12 changed files with 26 additions and 29 deletions
+2 -1
View File
@@ -28,6 +28,7 @@
#include "stdio-util.h"
#include "string-util.h"
#include "sync-util.h"
#include "terminal-util.h"
#include "tmpfile-util.h"
/* The maximum size of the file we'll read in one go in read_full_file() (64M). */
@@ -1459,7 +1460,7 @@ int read_line_full(FILE *f, size_t limit, ReadLineFlags flags, char **ret) {
* and don't call isatty() on an invalid fd */
flags |= READ_LINE_NOT_A_TTY;
else
flags |= isatty(fd) ? READ_LINE_IS_A_TTY : READ_LINE_NOT_A_TTY;
flags |= isatty_safe(fd) ? READ_LINE_IS_A_TTY : READ_LINE_NOT_A_TTY;
}
if (FLAGS_SET(flags, READ_LINE_IS_A_TTY))
break;