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
+3 -2
View File
@@ -30,8 +30,9 @@ static int write_to_terminal(const char *tty, const char *message) {
fd = open(tty, O_WRONLY|O_NONBLOCK|O_NOCTTY|O_CLOEXEC);
if (fd < 0)
return -errno;
if (!isatty(fd))
return -ENOTTY;
if (!isatty_safe(fd))
return -errno;
return loop_write_full(fd, message, SIZE_MAX, TIMEOUT_USEC);
}