diff options
author | Christopher Faylor <me@cgf.cx> | 2001-06-03 03:13:14 +0000 |
---|---|---|
committer | Christopher Faylor <me@cgf.cx> | 2001-06-03 03:13:14 +0000 |
commit | 77d130214c17469e2f6a6d9cb14ebe83acbb42dc (patch) | |
tree | a5c107608fbca34d1130e58c9e6848b2ac00fad0 /winsup/cygwin/signal.cc | |
parent | 7ceb1cac3a8f2a6822825347d1536f4507680704 (diff) | |
download | cygnal-77d130214c17469e2f6a6d9cb14ebe83acbb42dc.tar.gz cygnal-77d130214c17469e2f6a6d9cb14ebe83acbb42dc.tar.bz2 cygnal-77d130214c17469e2f6a6d9cb14ebe83acbb42dc.zip |
* 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/signal.cc')
-rw-r--r-- | winsup/cygwin/signal.cc | 19 |
1 files changed, 12 insertions, 7 deletions
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; |