Skip to content

Commit fe53d7c

Browse files
committed
nproc: Use Core::System::hardware_concurrency()
This is significantly simpler than parsing JSON and using the cpuinfo array length. This also has the side effect of making that command work on AArch64 and RISC-V, since ProcessorInfo is not implemented on those architectures yet.
1 parent 14cc6d8 commit fe53d7c

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

Userland/Utilities/nproc.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,9 @@
1111

1212
ErrorOr<int> serenity_main(Main::Arguments)
1313
{
14-
TRY(Core::System::pledge("stdio rpath"));
15-
auto file = TRY(Core::File::open("/sys/kernel/cpuinfo"sv, Core::File::OpenMode::Read));
14+
TRY(Core::System::pledge("stdio"));
1615

17-
auto buffer = TRY(file->read_until_eof());
18-
auto json = TRY(JsonValue::from_string(buffer));
19-
auto const& cpuinfo_array = json.as_array();
20-
outln("{}", cpuinfo_array.size());
16+
outln("{}", Core::System::hardware_concurrency());
2117

2218
return 0;
2319
}

0 commit comments

Comments
 (0)