aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/sleep-until.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/sleep-until.c b/src/sleep-until.c
index 176b24d..e06b552 100644
--- a/src/sleep-until.c
+++ b/src/sleep-until.c
@@ -34,6 +34,7 @@ int main(int argc, char* argv[])
int i, fd = -1, clocks = 0;
uint64_t _expirations;
int clockid = CLOCK_REALTIME;
+ const char* clockstr = "CLOCK_REALTIME";
if (argc < 2)
return 0;
@@ -55,11 +56,11 @@ int main(int argc, char* argv[])
$>cat /usr/include/bits/time.h | grep '^ *# *define *CLOCK_' | grep -Po 'CLOCK_[^[:blank:]]*' |
$>while read c; do
else if (!strcmp(p1, "${c}"))
- clockid = ${c};
+ clockid = ${c}, clockstr = "${c}";
$>done
else
- clockid = -1;
- clocks++;
+ clockid = -1, clockstr = "invalid";
+ clocks++;
continue;
parse_time:
@@ -80,7 +81,7 @@ $>done
value.it_value.tv_nsec = 0, value.it_value.tv_sec++;
}
- if (i == 0)
+ if (i == clocks)
largest_value = value;
else if (value.it_value.tv_sec > largest_value.it_value.tv_sec)
largest_value = value;
@@ -98,6 +99,11 @@ $>done
if (timerfd_settime(fd, TFD_TIMER_ABSTIME, &largest_value, NULL))
goto fail;
+ if (clock_gettime(clockid, &(value.it_value)) == 0)
+ fprintf(stderr, "%s: sleeping until %lli.%09li (current time: %lli.%09li, clock: %s)\n",
+ argv0, (long long int)(largest_value.it_value.tv_sec), largest_value.it_value.tv_nsec,
+ (long long int)(value.it_value.tv_sec), value.it_value.tv_nsec, clockstr);
+
for (;;)
{
if (clock_gettime(clockid, &(value.it_value)))