- <para><function>sd_journal_reliable_fd()</function>
- may be used to check whether the wakeup events from
- the file descriptor returned by
- <function>sd_journal_get_fd</function> are sufficient
- to track changes to the journal. If this call returns
- 0, it is necessary to regularly recheck for journal
- changes (suggestion: every 2s). If this call returns a
- positive integer this is not necessary, and wakeups
- from the file descriptor returned by
- <function>sd_journal_get_fd()</function> are
- sufficient as only source for wake-ups.</para>
+ <para><function>sd_journal_get_timeout()</function>
+ will return a timeout value for usage in <function>poll()</function>. This returns a value in microseconds since the epoch of CLOCK_MONOTONIC for timing out <function>poll()</function> in <literal>timeout_usec</literal>. See
+ <citerefentry><refentrytitle>clock_gettime</refentrytitle><manvolnum>2</manvolnum></citerefentry>
+ for details about
+ <literal>CLOCK_MONOTONIC</literal>. If there's no
+ timeout to wait for this will fill in
+ <literal>(uint64_t) -1</literal> instead. Note that
+ <function>poll()</function> takes a relative timeout
+ in milliseconds rather than an absolute timeout in
+ microseconds. To convert the absolute 'us' timeout into
+ relative 'ms', use code like the following:</para>
+
+ <programlisting>uint64_t t;
+int msec;
+sd_journal_get_timeout(m, &t);
+if (t == (uint64_t) -1)
+ msec = -1;
+else {
+ struct timespec ts;
+ uint64_t n;
+ clock_getttime(CLOCK_MONOTONIC, &ts);
+ n = (uint64_t) ts.tv_sec * 1000000 + ts.tv_nsec / 1000;
+ msec = t > n ? (int) ((t - n + 999) / 1000) : 0;
+}</programlisting>
+
+ <para>The code above does not do any error checking
+ for brevity's sake. The calculated <literal>msec</literal>
+ integer can be passed directly as
+ <function>poll()</function>'s timeout
+ parameter.</para>