From 41e442fea26f20ceb815306777d36361575825cc Mon Sep 17 00:00:00 2001 From: Hannes Reinecke Date: Mon, 26 Aug 2013 13:05:01 +0200 Subject: Allow ping to be interrupted Signed-off-by: Hannes Reinecke --- 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 @@ -103,6 +103,7 @@ static void usage(void) __attribute__((noreturn)); static u_short in_cksum(const u_short *addr, int len, u_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; @@ -262,6 +263,8 @@ main(int argc, char **argv) options |= F_SOURCEROUTE; } } + set_signal(SIGINT, doexit); + while (argc > 0) { target = *argv; @@ -1398,3 +1401,9 @@ void usage(void) ); exit(2); } + +static void doexit(int signo) +{ + exit (1); +} + -- 1.8.1.4