uptime: Use pledge()
This commit is contained in:
parent
3b3b4b0e04
commit
b2f9a60bdb
Notes:
sideshowbarker
2024-07-19 09:14:10 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/b2f9a60bdb8
1 changed files with 11 additions and 0 deletions
|
@ -25,15 +25,26 @@
|
|||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
if (pledge("stdio rpath", nullptr) < 0) {
|
||||
perror("pledge");
|
||||
return 1;
|
||||
}
|
||||
|
||||
FILE* fp = fopen("/proc/uptime", "r");
|
||||
if (!fp) {
|
||||
perror("fopen(/proc/uptime)");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (pledge("stdio", nullptr) < 0) {
|
||||
perror("pledge");
|
||||
return 1;
|
||||
}
|
||||
|
||||
char buffer[BUFSIZ];
|
||||
auto* p = fgets(buffer, sizeof(buffer), fp);
|
||||
if (!p) {
|
||||
|
|
Loading…
Add table
Reference in a new issue