mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 01:07:35 +00:00
ping: Use pledge()
This commit is contained in:
parent
41c504a33b
commit
409a4f7756
4 changed files with 295 additions and 1 deletions
|
@ -26,6 +26,11 @@ uint16_t internet_checksum(const void* ptr, size_t count)
|
|||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
if (pledge("stdio id inet dns", nullptr) < 0) {
|
||||
perror("pledge");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (argc != 2) {
|
||||
printf("usage: ping <host>\n");
|
||||
return 0;
|
||||
|
@ -42,6 +47,11 @@ int main(int argc, char** argv)
|
|||
return 1;
|
||||
}
|
||||
|
||||
if (pledge("stdio inet dns", nullptr) < 0) {
|
||||
perror("pledge");
|
||||
return 1;
|
||||
}
|
||||
|
||||
struct timeval timeout {
|
||||
1, 0
|
||||
};
|
||||
|
@ -57,6 +67,11 @@ int main(int argc, char** argv)
|
|||
return 1;
|
||||
}
|
||||
|
||||
if (pledge("stdio inet", nullptr) < 0) {
|
||||
perror("pledge");
|
||||
return 1;
|
||||
}
|
||||
|
||||
pid_t pid = getpid();
|
||||
|
||||
sockaddr_in peer_address;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue