mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 04:28:13 +00:00
uptime: Port to LibMain :^)
This commit is contained in:
parent
db36bdfeb7
commit
cd7b50a074
2 changed files with 6 additions and 9 deletions
|
@ -150,6 +150,7 @@ target_link_libraries(touch LibMain)
|
||||||
target_link_libraries(truncate LibMain)
|
target_link_libraries(truncate LibMain)
|
||||||
target_link_libraries(tt LibPthread)
|
target_link_libraries(tt LibPthread)
|
||||||
target_link_libraries(unzip LibArchive LibCompress)
|
target_link_libraries(unzip LibArchive LibCompress)
|
||||||
|
target_link_libraries(uptime LibMain)
|
||||||
target_link_libraries(userdel LibMain)
|
target_link_libraries(userdel LibMain)
|
||||||
target_link_libraries(usermod LibMain)
|
target_link_libraries(usermod LibMain)
|
||||||
target_link_libraries(utmpupdate LibMain)
|
target_link_libraries(utmpupdate LibMain)
|
||||||
|
|
|
@ -5,15 +5,14 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <AK/Format.h>
|
#include <AK/Format.h>
|
||||||
|
#include <LibCore/System.h>
|
||||||
|
#include <LibMain/Main.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
int main(int, char**)
|
ErrorOr<int> serenity_main(Main::Arguments)
|
||||||
{
|
{
|
||||||
if (pledge("stdio rpath", nullptr) < 0) {
|
TRY(Core::System::pledge("stdio rpath"));
|
||||||
perror("pledge");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
FILE* fp = fopen("/proc/uptime", "r");
|
FILE* fp = fopen("/proc/uptime", "r");
|
||||||
if (!fp) {
|
if (!fp) {
|
||||||
|
@ -21,10 +20,7 @@ int main(int, char**)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pledge("stdio", nullptr) < 0) {
|
TRY(Core::System::pledge("stdio"));
|
||||||
perror("pledge");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
char buffer[BUFSIZ];
|
char buffer[BUFSIZ];
|
||||||
auto* p = fgets(buffer, sizeof(buffer), fp);
|
auto* p = fgets(buffer, sizeof(buffer), fp);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue