mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 05:37:34 +00:00
uptime: Use pledge()
This commit is contained in:
parent
3b3b4b0e04
commit
b2f9a60bdb
1 changed files with 11 additions and 0 deletions
|
@ -25,15 +25,26 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
int main(int, char**)
|
int main(int, char**)
|
||||||
{
|
{
|
||||||
|
if (pledge("stdio rpath", nullptr) < 0) {
|
||||||
|
perror("pledge");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
FILE* fp = fopen("/proc/uptime", "r");
|
FILE* fp = fopen("/proc/uptime", "r");
|
||||||
if (!fp) {
|
if (!fp) {
|
||||||
perror("fopen(/proc/uptime)");
|
perror("fopen(/proc/uptime)");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pledge("stdio", nullptr) < 0) {
|
||||||
|
perror("pledge");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
char buffer[BUFSIZ];
|
char buffer[BUFSIZ];
|
||||||
auto* p = fgets(buffer, sizeof(buffer), fp);
|
auto* p = fgets(buffer, sizeof(buffer), fp);
|
||||||
if (!p) {
|
if (!p) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue