Hi,
I think nanosleep() is broken in that it returns elapsed time, not
remaining time. I worked out this fix, completely untested. If
someone wants to test and verify this fix, please have a go. To
properly test it you have to set up an ALARM signal and interrupt the
sleep I guess.
Thanks,
Marcus
2005-01-30 Marcus Brinkmann <[EMAIL PROTECTED]>
* sysdeps/mach/nanosleep.c (__nanosleep): Calculate remaining
time, not elapsed time.
--- nanosleep.c.org 2005-01-30 23:12:05.000000000 +0100
+++ nanosleep.c 2005-01-30 23:12:43.000000000 +0100
@@ -44,8 +44,16 @@ __nanosleep (const struct timespec *requ
if (remaining)
{
- timersub (&after, &before, &after);
- TIMEVAL_TO_TIMESPEC (&after, remaining);
+ struct timeval elapsed;
+ struct timeval remain;
+
+ timersub (&after, &before, &elapsed);
+ if (timercmp (&requested_time, &elapsed, <))
+ timerclear (&remain);
+ else
+ timersub (&requested_time, &elapsed, &remain);
+
+ TIMEVAL_TO_TIMESPEC (&remain, remaining);
}
return 0;
_______________________________________________
Bug-hurd mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/bug-hurd