nfsstat(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 the negative value we are fed becomes an extremely large unsigned int and the thread will sleep(3) for a long time indeed.
Fix: apply my patch, all we need is a simple check if the value is less than 1. This way an error message also occurs if we could not parse a number, since the return value in that case is 0.
version of the file i've used:
rcsid = "$FreeBSD: src/usr.bin/nfsstat/nfsstat.c,v 1.29 2009/12/13 03:14:06 delphij Exp$";
Patch attached with submission follows:
How-To-Repeat: > nfsstat -w -1
> nfsstat -w -3049
> nfsstat -w abc
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