netstat(1) -w should produce an error message and exit when fed a negative numerical value or a non numerical value at all, in which case atoi simply returns 0. This is the way iostat(8) handles this situation.
If we do not check for a negative value, then we will waste a lot of time sleeping before we are finally awaken.
If I'm not mistaken, we 'll wake up when the timer underflows and eventually turns 0.
Fix: apply my patch. all we need is a check if the value we are fed is a positive integer greater than 1. This way, an error message also occurs if we were not able to parse an integer since atoi(3) returns 0 in that case.
version of the file I used:
__FBSDID("$FreeBSD: src/usr.bin/netstat/main.c,v 1.103 2010/01/11 03:00:17 delphij Exp $");
Patch attached with submission follows:
How-To-Repeat: > netstat -w -1
> netstat -w abc
> netstat -w -30941
For bugs matching the following criteria:
Status: In Progress Changed: (is less than) 2014-06-01
Reset to default assignee and clear in-progress tags.
Mail being skipped