OSDN Git Service

* signal.cc (sleep): If interrupted by signal, return the
authorduda <duda>
Sat, 16 Sep 2000 13:19:52 +0000 (13:19 +0000)
committerduda <duda>
Sat, 16 Sep 2000 13:19:52 +0000 (13:19 +0000)
requested time minus the time actually slept.

winsup/cygwin/ChangeLog
winsup/cygwin/signal.cc

index 3382428..3507f5a 100644 (file)
@@ -1,3 +1,8 @@
+2000-09-16  Egor Duda  <deo@logos-m.ru>
+
+       * signal.cc (sleep): If interrupted by signal, return the
+       requested time minus the time actually slept.
+
 Fri Sep 15 22:30:40 2000  Christopher Faylor <cgf@cygnus.com>
 
        * exceptions.cc (handle_exceptions): Just "core dump" if SIGSEGV in signal thread.
index 0032201..f1b4dca 100644 (file)
@@ -44,19 +44,22 @@ extern "C"
 unsigned int
 sleep (unsigned int seconds)
 {
-  int res;
+  int rc;
   unsigned start_time;
+  unsigned int res;
 
   start_time = GetTickCount ();
 
   syscall_printf ("sleep (%d)", seconds);
-  res = WaitForSingleObject (signal_arrived, seconds * 1000);
-  if (res == WAIT_TIMEOUT)
-    {
-      syscall_printf ("0 = sleep (%d)", seconds);
-      return 0;
-    }
-  return (GetTickCount () - start_time)/1000;
+  rc = WaitForSingleObject (signal_arrived, seconds * 1000);
+  if (rc == WAIT_TIMEOUT)
+    res = 0;
+  else
+    res = seconds - (GetTickCount () - start_time)/1000;
+
+  syscall_printf ("%d = sleep (%d)", res, seconds);
+
+  return res;
 }
 
 extern "C"