iputils/iputils-ping-interrupt.diff

45 lines
916 B
Diff
Raw Normal View History

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>
---
ping.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/ping.c b/ping.c
index 0357c3d..83a7aad 100644
--- a/ping.c
+++ b/ping.c
@@ -98,6 +98,7 @@
static unsigned short in_cksum(const unsigned short *addr, int len, unsigned short salt);
static void pr_icmph(__u8 type, __u8 code, __u32 info, struct icmphdr *icp);
static int parsetos(char *str);
+static void doexit (int);
static struct {
struct cmsghdr cm;
@@ -504,6 +516,8 @@
options |= F_SOURCEROUTE;
}
}
+ set_signal(SIGINT, doexit);
+
while (argc > 0) {
target = *argv;
@@ -1629,3 +1643,9 @@
ping6_usage(1);
exit(2);
}
+
+static void doexit(int signo)
+{
+ exit (1);
+}
+
--
1.8.1.4