diff options
author | Andreas Baumann <mail@andreasbaumann.cc> | 2023-05-04 14:11:01 +0200 |
---|---|---|
committer | Andreas Baumann <mail@andreasbaumann.cc> | 2023-05-04 14:11:01 +0200 |
commit | 8233cf3eb30a934fe4993f42df5051d8a8944705 (patch) | |
tree | a42b4e21df106eb0aa9ca9ce88b688e5cf728550 | |
parent | c86a7ea4d3d86d39647eaf9250442af2dd6e3e93 (diff) | |
download | abase-8233cf3eb30a934fe4993f42df5051d8a8944705.tar.gz abase-8233cf3eb30a934fe4993f42df5051d8a8944705.tar.bz2 |
ping: fixed unreachable hosts and and interrupted system calls in receive
-rw-r--r-- | README | 1 | ||||
-rw-r--r-- | ping.c | 10 |
2 files changed, 8 insertions, 3 deletions
@@ -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 @@ -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) { |