Subject: Re: bug#9101: timeout should use setitimer if available

From: Paul Eggert <[email-masked]>
Date: Mon, 18 Jul 2011 09:44:08 -0700

On 07/18/11 03:01, Pádraig Brady wrote:
> I'll apply this soon.

Thanks for doing that. Some comments:

I see that my bug report was incoherent, as it was talking about
nanosecond resolution and setitimer, when I meant to be writing about
timer_settime (which *does* have nanosecond resolution).  Sorry about
that.

POSIX says that setitimer is obsolescent, and that applications should use
timer_settime.  How about if we add a gnulib module for timer_settime
and have 'timeout' use that instead?  (This could be a separate patch,
done later.)

   +  struct timespec ts = dtotimespec (duration);
   +  tv.tv_sec = MIN (ts.tv_sec, LONG_MAX); /* Assuming tv_sec is positive.  */

That second statement should be removed.  time_t is not necessarily
the same as 'long', and setitimer should work with values longer than
LONG_MAX, if time_t is wider than 'long'.  And parse_duration when
combined with dtotimespec guarantees that tv_sec is nonnegative here
(it might be zero), so that comment needs to be removed too.

   +      if (tv.tv_sec != LONG_MAX)

This LONG_MAX should be TYPE_MAXIMUM (time_t).

Of course all of this rounding-and-checking-for-overflow business
goes away once we go to timer_settime....