2014-01-25 15:10:50 +01:00
|
|
|
From 41e442fea26f20ceb815306777d36361575825cc Mon Sep 17 00:00:00 2001
|
|
|
|
From: Hannes Reinecke <hare@suse.de>
|
|
|
|
Date: Mon, 26 Aug 2013 13:05:01 +0200
|
|
|
|
Subject: Allow ping to be interrupted
|
|
|
|
|
|
|
|
Signed-off-by: Hannes Reinecke <hare@suse.de>
|
|
|
|
---
|
2018-07-04 00:02:17 +02:00
|
|
|
ping.c | 8 ++++++++
|
|
|
|
1 file changed, 8 insertions(+)
|
2014-01-25 15:10:50 +01:00
|
|
|
|
2019-05-24 19:12:38 +02:00
|
|
|
diff --git a/ping.c b/ping.c
|
|
|
|
index 06cc369..2c76677 100644
|
|
|
|
--- a/ping.c
|
|
|
|
+++ b/ping.c
|
|
|
|
@@ -92,6 +92,7 @@ static unsigned short in_cksum(const unsigned short *addr, int len, unsigned sho
|
|
|
|
static void pr_icmph(uint8_t type, uint8_t code, uint32_t info, struct icmphdr *icp);
|
2013-07-23 11:17:26 +02:00
|
|
|
static int parsetos(char *str);
|
2018-07-04 00:02:17 +02:00
|
|
|
static int parseflow(char *str);
|
2013-07-23 11:17:26 +02:00
|
|
|
+static void doexit (int);
|
|
|
|
|
2019-05-24 19:12:38 +02:00
|
|
|
static struct sockaddr_in source = { .sin_family = AF_INET };
|
|
|
|
char *device;
|
|
|
|
@@ -543,6 +544,8 @@ int ping4_run(int argc, char **argv, struct addrinfo *ai, socket_st *sock)
|
2013-07-23 11:17:26 +02:00
|
|
|
options |= F_SOURCEROUTE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
+ set_signal(SIGINT, doexit);
|
|
|
|
+
|
|
|
|
while (argc > 0) {
|
|
|
|
target = *argv;
|
|
|
|
|
2019-05-24 19:12:38 +02:00
|
|
|
@@ -1619,3 +1622,8 @@ void ping4_install_filter(socket_st *sock)
|
|
|
|
if (setsockopt(sock->fd, SOL_SOCKET, SO_ATTACH_FILTER, &filter, sizeof(filter)))
|
|
|
|
error(0, errno, _("WARNING: failed to install socket filter"));
|
2013-07-23 11:17:26 +02:00
|
|
|
}
|
|
|
|
+
|
2019-05-24 19:12:38 +02:00
|
|
|
+static void doexit(int signo __attribute__((unused)))
|
2013-07-23 11:17:26 +02:00
|
|
|
+{
|
|
|
|
+ exit (1);
|
|
|
|
+}
|
2019-05-24 19:12:38 +02:00
|
|
|
--
|
|
|
|
2.21.0
|
|
|
|
|