From: duda Date: Sat, 16 Sep 2000 13:19:52 +0000 (+0000) Subject: * signal.cc (sleep): If interrupted by signal, return the X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=5a454276edc35de11ab3f39e4319b566bf169057;p=pf3gnuchains%2Fpf3gnuchains3x.git * signal.cc (sleep): If interrupted by signal, return the requested time minus the time actually slept. --- diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 3382428309..3507f5a792 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,8 @@ +2000-09-16 Egor Duda + + * 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 * exceptions.cc (handle_exceptions): Just "core dump" if SIGSEGV in signal thread. diff --git a/winsup/cygwin/signal.cc b/winsup/cygwin/signal.cc index 00322018e3..f1b4dca920 100644 --- a/winsup/cygwin/signal.cc +++ b/winsup/cygwin/signal.cc @@ -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"