Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2001-06-03 07:13:14 +0400
committerChristopher Faylor <me@cgf.cx>2001-06-03 07:13:14 +0400
commit77d130214c17469e2f6a6d9cb14ebe83acbb42dc (patch)
treea5c107608fbca34d1130e58c9e6848b2ac00fad0 /winsup/cygwin
parent7ceb1cac3a8f2a6822825347d1536f4507680704 (diff)
* syscalls.cc (sleep): Try to be a little more accomodating of signal arrival.
Ensure that the signal handler is called.
Diffstat (limited to 'winsup/cygwin')
-rw-r--r--winsup/cygwin/ChangeLog5
-rw-r--r--winsup/cygwin/signal.cc19
2 files changed, 17 insertions, 7 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index 5f291312b..4c0fe3cce 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,3 +1,8 @@
+Sat Jun 2 23:11:52 2001 Christopher Faylor <cgf@cygnus.com>
+
+ * syscalls.cc (sleep): Try to be a little more accomodating of signal
+ arrival. Ensure that the signal handler is called.
+
Sat Jun 2 14:07:28 2001 Christopher Faylor <cgf@cygnus.com>
* cygheap.cc (cygheap_root::cygheap_rot): Remove constructor.
diff --git a/winsup/cygwin/signal.cc b/winsup/cygwin/signal.cc
index 8b10f416d..714c31f4b 100644
--- a/winsup/cygwin/signal.cc
+++ b/winsup/cygwin/signal.cc
@@ -66,19 +66,24 @@ extern "C" unsigned int
sleep (unsigned int seconds)
{
int rc;
- unsigned start_time;
- unsigned int res;
sigframe thisframe (mainthread);
+ DWORD ms, start_time, end_time;
+ ms = seconds * 1000;
start_time = GetTickCount ();
-
+ end_time = start_time + (seconds * 1000);
syscall_printf ("sleep (%d)", seconds);
- rc = WaitForSingleObject (signal_arrived, seconds * 1000);
- if (rc == WAIT_TIMEOUT)
- res = 0;
+
+ rc = WaitForSingleObject (signal_arrived, ms);
+ DWORD now = GetTickCount ();
+ if (rc == WAIT_TIMEOUT || now >= end_time)
+ ms = 0;
else
- res = seconds - (GetTickCount () - start_time)/1000;
+ ms = end_time - now;
+ if (WaitForSingleObject (signal_arrived, 0) == WAIT_OBJECT_0)
+ (void) thisframe.call_signal_handler ();
+ DWORD res = (ms + 500) / 1000;
syscall_printf ("%d = sleep (%d)", res, seconds);
return res;