[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <200908101409.44106.bcook@bpointsys.com>
Date: Mon, 10 Aug 2009 14:09:43 -0500
From: Brent Cook <bcook@...intsys.com>
To: Michele BOLOGNA <michele.bologna@...il.com>
Cc: yoshfuji@...ux-ipv6.org, netdev@...r.kernel.org
Subject: Re: strange behaviour in ping when specifying timeout in msec
On Wednesday 05 August 2009 06:27:14 pm Michele BOLOGNA wrote:
> Dear Mr. Yoshifuji,
> I recently noticed a strange behaviour in ping from iputils.
>
> First of all some information:
> mbologna@...tune:~$ ping -V
> ping utility, iputils-sss20071127
>
> Now, I want to specify a timeout and after it expires I would like
> that ping exits, regardless of the packets received, so I use the -W
> option:
>
> -W timeout
> Time to wait for a response, in seconds. The option affects
> only timeout in absense of any responses, otherwise ping waits for two
> RTTs.
If you check out the source to ping, you will see that the results of non-
integer arguments to -W is undefined, since atoi cannot detect errors. In your
case, its probably being interpreted as 0. You can enter almost any value for
-W without it showing an error, e.g. 'cat' or 'dog'.
case 'W':
lingertime = atoi(optarg);
if (lingertime < 0 || lingertime > INT_MAX/1000000) {
fprintf(stderr, "ping: bad linger time.\n");
exit(2);
}
lingertime *= 1000;
break;
Your best bet is perhaps to modify ping to parse time using strtof perhaps.
- Brent
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists