* syscalls.cc (sleep): Try to be a little more accomodating of signal arrival.

Ensure that the signal handler is called.
This commit is contained in:
Christopher Faylor 2001-06-03 03:13:14 +00:00
parent 7ceb1cac3a
commit 77d130214c
2 changed files with 18 additions and 8 deletions

View File

@ -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> Sat Jun 2 14:07:28 2001 Christopher Faylor <cgf@cygnus.com>
* cygheap.cc (cygheap_root::cygheap_rot): Remove constructor. * cygheap.cc (cygheap_root::cygheap_rot): Remove constructor.

View File

@ -66,19 +66,24 @@ extern "C" unsigned int
sleep (unsigned int seconds) sleep (unsigned int seconds)
{ {
int rc; int rc;
unsigned start_time;
unsigned int res;
sigframe thisframe (mainthread); sigframe thisframe (mainthread);
DWORD ms, start_time, end_time;
ms = seconds * 1000;
start_time = GetTickCount (); start_time = GetTickCount ();
end_time = start_time + (seconds * 1000);
syscall_printf ("sleep (%d)", seconds); syscall_printf ("sleep (%d)", seconds);
rc = WaitForSingleObject (signal_arrived, seconds * 1000);
if (rc == WAIT_TIMEOUT)
res = 0;
else
res = seconds - (GetTickCount () - start_time)/1000;
rc = WaitForSingleObject (signal_arrived, ms);
DWORD now = GetTickCount ();
if (rc == WAIT_TIMEOUT || now >= end_time)
ms = 0;
else
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); syscall_printf ("%d = sleep (%d)", res, seconds);
return res; return res;