Re: timer_settime() and ECANCELED
From: Thomas Gleixner
Date: Thu Apr 02 2020 - 09:35:08 EST
"Michael Kerrisk (man-pages)" <mtk.manpages@xxxxxxxxx> writes:
> NOTES
> Suppose the following scenario for CLOCK_REALTIME or CLOCK_REALâ
> TIME_ALARM timer that was created with timerfd_create():
>
> (a) The timer has been started (timerfd_settime()) with the
> TFD_TIMER_ABSTIME and TFD_TIMER_CANCEL_ON_SET flags;
>
> (b) A discontinuous change (e.g. settimeofday(2)) is subsequently
> made to the CLOCK_REALTIME clock; and
>
> (c) the caller once more calls timerfd_settime() to rearm the
> timer (without first doing a read(2) on the file descriptor).
>
> In this case the following occurs:
>
> Â The timerfd_settime() returns -1 with errno set to ECANCELED.
> (This enables the caller to know that the previous timer was
> affected by a discontinuous change to the clock.)
>
> Â The timer is successfully rearmed with the settings provided in
> the second timerfd_settime() call. (This was probably an impleâ
> mentation accident, but won't be fixed now, in case there are
> applications that depend on this behaviour.)
Clear enough.
Thanks Michael!