ladybird/Userland/Utilities/nproc.cpp
Andreas Kling 21a5fb0fa2 LibCore+LibSystem: Move syscall wrappers from LibSystem to LibCore
With this change, System::foo() becomes Core::System::foo().

Since LibCore builds on other systems than SerenityOS, we now have to
make sure that wrappers work with just a standard C library underneath.
2021-11-23 11:33:36 +01:00

24 lines
605 B
C++

/*
* Copyright (c) 2021, Peter Elliott <pelliott@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <AK/JsonObject.h>
#include <LibCore/File.h>
#include <LibCore/System.h>
#include <LibMain/Main.h>
ErrorOr<int> serenity_main(Main::Arguments)
{
TRY(Core::System::pledge("stdio rpath", nullptr));
auto file = TRY(Core::File::open("/proc/cpuinfo", Core::OpenMode::ReadOnly));
auto buffer = file->read_all();
auto json = TRY(JsonValue::from_string({ buffer }));
auto const& cpuinfo_array = json.as_array();
outln("{}", cpuinfo_array.size());
return 0;
}