From 92e6532bf139aca0be568b545e8c0a47dc7f665f Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Thu, 16 Dec 2021 19:24:58 +0100 Subject: [PATCH] LibCore: Add syscall wrapper for isatty() --- Userland/Libraries/LibCore/System.cpp | 8 ++++++++ Userland/Libraries/LibCore/System.h | 1 + 2 files changed, 9 insertions(+) diff --git a/Userland/Libraries/LibCore/System.cpp b/Userland/Libraries/LibCore/System.cpp index 423d0b1ca0..e99cf059c8 100644 --- a/Userland/Libraries/LibCore/System.cpp +++ b/Userland/Libraries/LibCore/System.cpp @@ -416,4 +416,12 @@ ErrorOr setegid(gid_t gid) return {}; } +ErrorOr isatty(int fd) +{ + int rc = ::isatty(fd); + if (rc < 0) + return Error::from_syscall("isatty"sv, -errno); + return rc == 1; +} + } diff --git a/Userland/Libraries/LibCore/System.h b/Userland/Libraries/LibCore/System.h index 47f2d6c92f..f942c51c40 100644 --- a/Userland/Libraries/LibCore/System.h +++ b/Userland/Libraries/LibCore/System.h @@ -59,5 +59,6 @@ ErrorOr setuid(uid_t); ErrorOr seteuid(uid_t); ErrorOr setgid(gid_t); ErrorOr setegid(gid_t); +ErrorOr isatty(int fd); }