diff --git a/Userland/Utilities/CMakeLists.txt b/Userland/Utilities/CMakeLists.txt index 612063e393..6849c9ff12 100644 --- a/Userland/Utilities/CMakeLists.txt +++ b/Userland/Utilities/CMakeLists.txt @@ -79,6 +79,7 @@ target_link_libraries(markdown-check LibMarkdown) target_link_libraries(matroska LibVideo) target_link_libraries(md LibMarkdown) target_link_libraries(notify LibGUI) +target_link_libraries(nproc LibMain) target_link_libraries(open LibDesktop) target_link_libraries(pape LibGUI) target_link_libraries(passwd LibCrypt) diff --git a/Userland/Utilities/nproc.cpp b/Userland/Utilities/nproc.cpp index 588b112605..8d91d200fc 100644 --- a/Userland/Utilities/nproc.cpp +++ b/Userland/Utilities/nproc.cpp @@ -6,25 +6,17 @@ #include #include -#include -#include +#include +#include -int main() +ErrorOr serenity_main(Main::Arguments) { - if (pledge("stdio rpath", nullptr) < 0) { - perror("pledge"); - return 1; - } - - auto file = Core::File::construct("/proc/cpuinfo"); - if (!file->open(Core::OpenMode::ReadOnly)) { - perror("Core::File::open()"); - return 1; - } + TRY(System::pledge("stdio rpath", nullptr)); + auto file = TRY(Core::File::open("/proc/cpuinfo", Core::OpenMode::ReadOnly)); auto buffer = file->read_all(); - auto json = JsonValue::from_string({ buffer }); - auto cpuinfo_array = json.value().as_array(); + auto json = TRY(JsonValue::from_string({ buffer })); + auto const& cpuinfo_array = json.as_array(); outln("{}", cpuinfo_array.size()); return 0;