From 6d2f9f0316def3e51b0227fd63f40c5a8f6665e2 Mon Sep 17 00:00:00 2001 From: Tim Ledbetter Date: Wed, 12 Jul 2023 19:49:32 +0100 Subject: [PATCH] less: Replace LibC calls with their LibCore equivalents --- Userland/Utilities/less.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Userland/Utilities/less.cpp b/Userland/Utilities/less.cpp index 0a8f885c0b..fd2801d545 100644 --- a/Userland/Utilities/less.cpp +++ b/Userland/Utilities/less.cpp @@ -9,9 +9,7 @@ #include #include #include -#include #include -#include #include #include @@ -181,8 +179,8 @@ public: { // First, we get the current size of the window. struct winsize window; - if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &window) == -1) { - perror("ioctl(2)"); + if (auto maybe_error = Core::System::ioctl(STDOUT_FILENO, TIOCGWINSZ, &window); maybe_error.is_error()) { + warnln("ioctl(2): {}", strerror(maybe_error.error().code())); return; } @@ -522,9 +520,11 @@ ErrorOr serenity_main(Main::Arguments arguments) // On SIGWINCH set this flag so that the main-loop knows when the terminal // has been resized. - signal(SIGWINCH, [](auto) { + struct sigaction resize_action; + resize_action.sa_handler = [](auto) { g_resized = true; - }); + }; + TRY(Core::System::sigaction(SIGWINCH, &resize_action, nullptr)); TRY(Core::System::pledge("stdio tty sigaction")); @@ -535,7 +535,7 @@ ErrorOr serenity_main(Main::Arguments arguments) prompt = "--More--"; } - if (!isatty(STDOUT_FILENO)) { + if (!TRY(Core::System::isatty(STDOUT_FILENO))) { cat_file(file); return 0; }