From 77d130214c17469e2f6a6d9cb14ebe83acbb42dc Mon Sep 17 00:00:00 2001 From: Christopher Faylor Date: Sun, 3 Jun 2001 03:13:14 +0000 Subject: * syscalls.cc (sleep): Try to be a little more accomodating of signal arrival. Ensure that the signal handler is called. --- winsup/cygwin/ChangeLog | 5 +++++ winsup/cygwin/signal.cc | 19 ++++++++++++------- 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 + + * 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 * 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; -- cgit v1.2.3