Bug 191493

Summary: watch -n doesn't handle large integers properly
Product: [Fedora] Fedora Reporter: Stephen Kratzer <kratzers>
Component: procpsAssignee: Karel Zak <kzak>
Status: CLOSED ERRATA QA Contact: Brian Brock <bbrock>
Severity: medium Docs Contact:
Priority: medium    
Version: 5   
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2006-06-21 17:31:18 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
Patch to watch.c none

Description Stephen Kratzer 2006-05-12 13:32:43 UTC
Created attachment 128937 [details]
Patch to watch.c

Comment 1 Stephen Kratzer 2006-05-12 13:32:43 UTC
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):

3.2.5, 3.2.6

How reproducible:

Always

Steps to Reproduce:
1. issue command: watch -n 4295 "echo . >> test.out"
2. wait 10 seconds
3. ctrl-c
  
Actual results:

The echo command is executed at rapid intervals, and the test.out file is 
filled with lines of ".\n"

Expected results:

The echo command should be executed every 4295 seconds or whatever interval in 
seconds as passed to the -n flag

Additional info:

Package: procps
Version: 3.2.6
Kernel: 2.6.16-1.2096_FC4
C Library: glibc-2.3.6-3

Comment 2 Karel Zak 2006-06-01 10:40:57 UTC
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);


Comment 3 Fedora Update System 2006-06-01 14:27:26 UTC
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.

Comment 4 Albert Cahalan 2006-06-02 04:56:00 UTC
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.