summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Baumann <mail@andreasbaumann.cc>2023-05-04 14:11:01 +0200
committerAndreas Baumann <mail@andreasbaumann.cc>2023-05-04 14:11:01 +0200
commit8233cf3eb30a934fe4993f42df5051d8a8944705 (patch)
treea42b4e21df106eb0aa9ca9ce88b688e5cf728550
parentc86a7ea4d3d86d39647eaf9250442af2dd6e3e93 (diff)
downloadabase-8233cf3eb30a934fe4993f42df5051d8a8944705.tar.gz
abase-8233cf3eb30a934fe4993f42df5051d8a8944705.tar.bz2
ping: fixed unreachable hosts and and interrupted system calls in receive
-rw-r--r--README1
-rw-r--r--ping.c10
2 files changed, 8 insertions, 3 deletions
diff --git a/README b/README
index 99ae704..3eca7a0 100644
--- a/README
+++ b/README
@@ -13,6 +13,7 @@ Currently it contains the following:
- a 'netstat': see list of active connections of a machine
- 'mkswap'
- 'fsck.ext4', 'mkfs.ext4': if ext4 is the only file system we support
+- 'nbd-client': for NBD root mounts
Note: abase is a shameless copy of sbase/ubase in certain areas like
the Makefile, libutil, etc. This might also make an integration into
diff --git a/ping.c b/ping.c
index e2d9fd0..148e406 100644
--- a/ping.c
+++ b/ping.c
@@ -174,9 +174,13 @@ main(int argc, char *argv[])
unsigned int address_len = sizeof(sending_address);
if (recvfrom(fd, &packet, sizeof(packet), 0, (struct sockaddr *)&sending_address, &address_len) <= 0) {
- freeaddrinfo(addresses);
- close(fd);
- eprintf("Unable to receive packet from '%s': %s\n", host, strerror(errno));
+ if (errno == EAGAIN || errno == EINTR) {
+ // ok, not reachable or interrupted by Ctrl-C
+ } else {
+ freeaddrinfo(addresses);
+ close(fd);
+ eprintf("Unable to receive packet from '%s': %s\n", host, strerror(errno));
+ }
} else {
if (sent) {
if (packet.header.type != 69 || packet.header.code != 0) {