Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 8 Sep 1998 06:11:31 +1000
From:      Bruce Evans <bde@zeta.org.au>
To:        ache@nagual.pp.ru, current@FreeBSD.ORG
Subject:   Re: new sleep.c & SIGALRM problem
Message-ID:  <199809072011.GAA16751@godzilla.zeta.org.au>

next in thread | raw e-mail | index | archive | help
>When SIGALRM comes at INT_MAX seconds, new sleep code kill the program
>instead of stopping sleep.

This doesn't matter if ints are 32 bits, because the error can't be
detected without sleeping for a INT_MAX seconds (about 68 years).
The previous version was correct enough for the same reason.

>Previous code works, so LONG_MAX comparison
>must be restored, it is pretty legal in C.

The LONG_MAX was broken on alphas because time_t is int32_t on alphas,
so UINT_MAX < LONG_MAX but tv_sec = UINT_MAX overflows to -1 and
sleep(UINT_MAX) returns immediately.  This should be handled by
defining TIME_T_MAX in a header file and comparing with it instead
of LONG_MAX or INT_MAX.  There is no need to loop, because time_t
must have a range large enough to cover all interesting times.

Bruce

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199809072011.GAA16751>