delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2000/05/09/05:01:04

Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT sourceware DOT cygnus DOT com>
List-Archive: <http://sourceware.cygnus.com/ml/cygwin/>
List-Post: <mailto:cygwin AT sourceware DOT cygnus DOT com>
List-Help: <mailto:cygwin-help AT sourceware DOT cygnus DOT com>, <http://sourceware.cygnus.com/ml/#faqs>
Sender: cygwin-owner AT sourceware DOT cygnus DOT com
Delivered-To: mailing list cygwin AT sourceware DOT cygnus DOT com
Date: Tue, 9 May 2000 12:02:54 +0200
Message-Id: <200005091002.MAA04192@endor.e.kth.se>
X-Authentication-Warning: endor.e.kth.se: lha set sender to lha AT s3 DOT kth DOT se using -f
From: Love <lha AT stacken DOT kth DOT se>
To: cygwin AT sourceware DOT cygnus DOT com
Subject: setitimer warps

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019