File iputils-ping-interrupt.diff of Package iputils
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(+)
Index: iputils/ping.c
===================================================================
--- iputils.orig/ping.c
+++ iputils/ping.c
@@ -97,6 +97,7 @@ static void usage(void) __attribute__((noreturn));
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;
@@ -579,6 +580,8 @@ int ping4_run(int argc, char **argv, struct addrinfo *ai, socket_st *sock)
options |= F_SOURCEROUTE;
}
}
+ set_signal(SIGINT, doexit);
+
while (argc > 0) {
target = *argv;
@@ -1699,3 +1702,9 @@ void usage(void)
ping6_usage(1);
exit(2);
}
+
+static void doexit(int signo)
+{
+ exit (1);
+}
+