summaryrefslogtreecommitdiff
path: root/Userland/Utilities
diff options
context:
space:
mode:
authormjz19910 <matthias291999@gmail.com>2022-01-02 01:49:26 -0700
committerBrian Gianforcaro <b.gianfo@gmail.com>2022-01-02 09:42:56 +0000
commitcd7b50a07471a06bd6d03293ba9eb2e9c0c75b1f (patch)
tree5f6a3dd7b01259bda2a5f3b65da22be12038f9c7 /Userland/Utilities
parentdb36bdfeb71f7f5349f4ca34ab1bc3a892069f98 (diff)
downloadserenity-cd7b50a07471a06bd6d03293ba9eb2e9c0c75b1f.zip
uptime: Port to LibMain :^)
Diffstat (limited to 'Userland/Utilities')
-rw-r--r--Userland/Utilities/CMakeLists.txt1
-rw-r--r--Userland/Utilities/uptime.cpp14
2 files changed, 6 insertions, 9 deletions
diff --git a/Userland/Utilities/CMakeLists.txt b/Userland/Utilities/CMakeLists.txt
index 0df6a63878..fbcd31a5b7 100644
--- a/Userland/Utilities/CMakeLists.txt
+++ b/Userland/Utilities/CMakeLists.txt
@@ -150,6 +150,7 @@ target_link_libraries(touch LibMain)
target_link_libraries(truncate LibMain)
target_link_libraries(tt LibPthread)
target_link_libraries(unzip LibArchive LibCompress)
+target_link_libraries(uptime LibMain)
target_link_libraries(userdel LibMain)
target_link_libraries(usermod LibMain)
target_link_libraries(utmpupdate LibMain)
diff --git a/Userland/Utilities/uptime.cpp b/Userland/Utilities/uptime.cpp
index 530e85b88a..ce698461ac 100644
--- a/Userland/Utilities/uptime.cpp
+++ b/Userland/Utilities/uptime.cpp
@@ -5,15 +5,14 @@
*/
#include <AK/Format.h>
+#include <LibCore/System.h>
+#include <LibMain/Main.h>
#include <stdio.h>
#include <unistd.h>
-int main(int, char**)
+ErrorOr<int> serenity_main(Main::Arguments)
{
- if (pledge("stdio rpath", nullptr) < 0) {
- perror("pledge");
- return 1;
- }
+ TRY(Core::System::pledge("stdio rpath"));
FILE* fp = fopen("/proc/uptime", "r");
if (!fp) {
@@ -21,10 +20,7 @@ int main(int, char**)
return 1;
}
- if (pledge("stdio", nullptr) < 0) {
- perror("pledge");
- return 1;
- }
+ TRY(Core::System::pledge("stdio"));
char buffer[BUFSIZ];
auto* p = fgets(buffer, sizeof(buffer), fp);