aboutsummaryrefslogtreecommitdiff
path: root/games/grdc
diff options
context:
space:
mode:
authorXin LI <delphij@FreeBSD.org>2010-02-10 18:20:20 +0000
committerXin LI <delphij@FreeBSD.org>2010-02-10 18:20:20 +0000
commiteb1930d3f2f9c7c53e29df8a34dcfd98fd2b803a (patch)
tree1a33eced7f53ad58600435ae67886c0c1b264f97 /games/grdc
parent0b0b48c06af49f49f82bbc874ad44a49a90db11a (diff)
Notes
Diffstat (limited to 'games/grdc')
-rw-r--r--games/grdc/grdc.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/games/grdc/grdc.c b/games/grdc/grdc.c
index d27b10ed79160..c467b533e28ec 100644
--- a/games/grdc/grdc.c
+++ b/games/grdc/grdc.c
@@ -59,6 +59,7 @@ main(argc, argv)
int argc;
char **argv;
{
+struct timespec ts;
long t, a;
int i, j, s, k;
int n;
@@ -136,9 +137,9 @@ int t12;
attrset(COLOR_PAIR(2));
}
+ time(&now);
do {
mask = 0;
- time(&now);
tm = localtime(&now);
set(tm->tm_sec%10, 0);
set(tm->tm_sec/10, 4);
@@ -193,7 +194,19 @@ int t12;
}
movto(6, 0);
refresh();
- sleep(1);
+ clock_gettime(CLOCK_REALTIME_FAST, &ts);
+ if (ts.tv_sec == now) {
+ if (ts.tv_nsec > 0) {
+ ts.tv_sec = 0;
+ ts.tv_nsec = 1000000000 - ts.tv_nsec;
+ } else {
+ ts.tv_sec = 1;
+ ts.tv_nsec = 0;
+ }
+ nanosleep(&ts, NULL);
+ now = ts.tv_sec + 1;
+ } else
+ now = ts.tv_sec;
if (sigtermed) {
standend();
clear();