diff options
author | Florian Obser <florian@cvs.openbsd.org> | 2018-07-18 13:55:40 +0000 |
---|---|---|
committer | Florian Obser <florian@cvs.openbsd.org> | 2018-07-18 13:55:40 +0000 |
commit | df669b2b4681aed7ff3ef5469f9c04f23e2d8262 (patch) | |
tree | 2db32fcad1a2624b43defda772846b5d8ac93a6d /sbin | |
parent | 090bc8e30aceb6283e869b1e2b88fdff699b3356 (diff) |
When running flood ping with count packets (-c) set an alarm after
sending all packets otherwise ping will wait forever to see all
answers - which might not arrive on lossy links.
Problem pointed out by, input & OK claudio
Diffstat (limited to 'sbin')
-rw-r--r-- | sbin/ping/ping.c | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/sbin/ping/ping.c b/sbin/ping/ping.c index 54846f6c9eb..520f3226910 100644 --- a/sbin/ping/ping.c +++ b/sbin/ping/ping.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ping.c,v 1.225 2018/04/11 16:03:58 zhuk Exp $ */ +/* $OpenBSD: ping.c,v 1.226 2018/07/18 13:55:39 florian Exp $ */ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -817,8 +817,25 @@ main(int argc, char *argv[]) } if (options & F_FLOOD) { - (void)pinger(s); - timeout = 10; + if (pinger(s) != 0) { + (void)signal(SIGALRM, onsignal); + timeout = INFTIM; + if (nreceived) { + itimer.it_value.tv_sec = 2 * tmax / + 1000; + if (itimer.it_value.tv_sec == 0) + itimer.it_value.tv_sec = 1; + } else + itimer.it_value.tv_sec = maxwait; + itimer.it_interval.tv_sec = 0; + itimer.it_interval.tv_usec = 0; + itimer.it_value.tv_usec = 0; + (void)setitimer(ITIMER_REAL, &itimer, NULL); + + /* When the alarm goes off we are done. */ + seenint = 1; + } else + timeout = 10; } else timeout = INFTIM; |