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; }