From c8bb99e577880bb1660a2cbabf18b0b90ad4b7c8 Mon Sep 17 00:00:00 2001 From: Ian Dowse Date: Sun, 8 Feb 2004 21:59:17 +0000 Subject: [PATCH] Certain ICMP error replies cause ping to perform a reverse DNS lookup on an IP address from the packet (such as the IP that sent a TTL exceeded error). If the DNS lookup takes a long time, ^C will appear to be ineffective since the SIGINT handler just sets a flag and returns. Work around this by exiting immediately on receipt of a second SIGINT when DNS lookups are enabled. PR: bin/4696 MFC after: 1 week --- sbin/ping/ping.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/sbin/ping/ping.c b/sbin/ping/ping.c index cf01858e5d46..8db4afe2fa05 100644 --- a/sbin/ping/ping.c +++ b/sbin/ping/ping.c @@ -830,6 +830,12 @@ stopit(sig) int sig __unused; { + /* + * When doing reverse DNS lookups, the finish_up flag might not + * be noticed for a while. Just exit if we get a second SIGINT. + */ + if (!(options & F_NUMERIC) && finish_up) + _exit(nreceived ? 0 : 2); finish_up = 1; }