Break-out logging and time-related functions into lib modules
[khatus.git] / x5 / khatus_lib_time.c
CommitLineData
17a27e48
SK
1#include <errno.h>
2#include <math.h>
3#include <stdio.h>
4#include <string.h>
5#include <time.h>
6
7#include "khatus_lib_log.h"
8#include "khatus_lib_time.h"
9
10void
11snooze(struct timespec *t)
12{
13 struct timespec remainder;
14 int result;
15
16 result = nanosleep(t, &remainder);
17
18 if (result < 0) {
19 if (errno == EINTR) {
20 warn(
21 "nanosleep interrupted. Remainder: "
22 "{ tv_sec = %ld, tv_nsec = %ld }",
23 remainder.tv_sec, remainder.tv_nsec);
24 /* No big deal if we occasionally sleep less,
25 * so not attempting to correct after an interruption.
26 */
27 } else {
28 fatal("nanosleep: %s\n", strerror(errno));
29 }
30 }
31}
This page took 0.027574 seconds and 4 git commands to generate.