uptime: Port to LibMain :^)

This commit is contained in:
mjz19910 2022-01-02 01:49:26 -07:00 committed by Brian Gianforcaro
parent db36bdfeb7
commit cd7b50a074
Notes: sideshowbarker 2024-07-17 21:48:37 +09:00
2 changed files with 6 additions and 9 deletions

View File

@ -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)

View File

@ -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);