MEDIUM: wdt: fall back to CLOCK_REALTIME if CLOCK_THREAD_CPUTIME is not available
At least FreeBSD has a fully functional CLOCK_THREAD_CPUTIME but it
cannot create a timer on it. This is not a problem since our timer is
only used to measure each thread's usage using now_cpu_time_thread().
So by just replacing this clock with CLOCK_REALTIME we allow such
platforms to periodically call the wdt and check the thread's CPU usage.
The consequence is that even on a totally idle system there will still
be a few extra periodic wakeups, but the watchdog becomes usable there
as well.
diff --git a/src/wdt.c b/src/wdt.c
index 0c405b9..4adc33d 100644
--- a/src/wdt.c
+++ b/src/wdt.c
@@ -143,7 +143,8 @@
sev.sigev_notify = SIGEV_SIGNAL;
sev.sigev_signo = WDTSIG;
sev.sigev_value.sival_int = tid;
- if (timer_create(ti->clock_id, &sev, &ti->wd_timer) == -1)
+ if (timer_create(ti->clock_id, &sev, &ti->wd_timer) == -1 &&
+ timer_create(CLOCK_REALTIME, &sev, &ti->wd_timer) == -1)
goto fail1;
if (!wdt_ping(tid))