Red Hat Bugzilla – Bug 191493
watch -n doesn't handle large integers properly
Last modified: 2007-11-30 17:11:32 EST
Created attachment 128937 [details]
Patch to watch.c
Description of problem:
Passing integers larger than 4294 (ULONG_MAX / 1000000 on a 32-bit machine) to
watch -n will cause unexpected behavior.
Version-Release number of selected component (if applicable):
Steps to Reproduce:
1. issue command: watch -n 4295 "echo . >> test.out"
2. wait 10 seconds
The echo command is executed at rapid intervals, and the test.out file is
filled with lines of ".\n"
The echo command should be executed every 4295 seconds or whatever interval in
seconds as passed to the -n flag
C Library: glibc-2.3.6-3
Thanks for your report. Your solution is not backward compatible, I think better
will be use same solution like in the top command:
- usleep(interval * 1000000);
+ tv.tv_sec = (long) interval;
+ tv.tv_usec = (interval - (int) interval) * 1000000;
+ select(0, NULL, NULL, NULL, &tv);
procps-3.2.6-3.4 has been pushed for fc5, which should resolve this issue. If these problems are still present in this version, then please make note of it in this bug report.
I'd like to know why such a value is being used.
Would it hurt to cap the value at 4000? That is
over an hour.