summaryrefslogtreecommitdiff
path: root/ping.c
diff options
context:
space:
mode:
Diffstat (limited to 'ping.c')
-rw-r--r--ping.c10
1 files changed, 7 insertions, 3 deletions
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) {