Mail Archives: cygwin/2000/05/09/05:01:04
Settimer warps for too large values of itimer.it_value.tv_sec
Appended program shows the problem.
: DATAN ; gcc -o getitimer getitimer.c
: DATAN ; ./getitimer
Alarm clock
This patch should fix the problem:
Index: window.cc
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/window.cc,v
retrieving revision 1.3
diff -u -r1.3 window.cc
--- winsup/cygwin/window.cc 2000/03/07 05:33:09 1.3
+++ winsup/cygwin/window.cc 2000/05/09 09:49:02
@@ -154,6 +154,12 @@
set_errno (EINVAL);
return -1;
}
+ /* Check if we will wrap */
+ if (itv.it_value.tv_sec >= UINT_MAX / 1000)
+ {
+ set_errno (EINVAL);
+ return -1;
+ }
if (timer_active)
{
KillTimer (gethwnd(), timer_active);
Thanks,
Love
------ getitimer.c -----
#include <sys/types.h>
#include <sys/time.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <limits.h>
int
main(int argc, char **argv)
{
struct itimerval itimer;
itimer.it_value.tv_sec = INT_MAX;
itimer.it_value.tv_usec = 0;
itimer.it_interval.tv_sec = 0;
itimer.it_interval.tv_usec = 0;
if (setitimer (ITIMER_REAL, &itimer, NULL) != 0) {
fprintf (stderr, "setitimer failed\n");
exit (1);
}
sleep (10);
return 0;
}
--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe AT sourceware DOT cygnus DOT com
- Raw text -