diff options
author | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2014-11-19 03:27:46 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2014-11-19 03:27:46 +0000 |
commit | e9ce9c47b231b4e8a0c36c51436e60f571c26c99 (patch) | |
tree | 68deb288731ade26ab02923f9b1df941cc061274 | |
parent | 41c9ce6635d9dd1d807dbfae05b07c309f2f80ed (diff) |
Bugfix: run for the specified number of seconds as described in the manual,
not for a fixed number of iterations. This makes a difference on terminals
not fast enough to update every second, in particular in -s mode.
Inspired by FreeBSD, but implemented differently with less bugs.
Patch from pjanzen@, slightly tweaked by me.
-rw-r--r-- | games/grdc/grdc.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/games/grdc/grdc.c b/games/grdc/grdc.c index 7595da7728d..1b33b01c803 100644 --- a/games/grdc/grdc.c +++ b/games/grdc/grdc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: grdc.c,v 1.18 2014/11/18 20:09:45 tedu Exp $ */ +/* $OpenBSD: grdc.c,v 1.19 2014/11/19 03:27:45 schwarze Exp $ */ /* * * Copyright 2002 Amos Shapir. Public domain. @@ -62,7 +62,7 @@ main(int argc, char *argv[]) int i, j, s, k; int scrol; int n = 0; - struct timeval nowtv; + struct timeval nowtv, endtv; struct timespec delay; const char *errstr; long scroldelay = 50000000; @@ -120,6 +120,8 @@ main(int argc, char *argv[]) gettimeofday(&nowtv, NULL); TIMEVAL_TO_TIMESPEC(&nowtv, &now); + if (n) + endtv.tv_sec = nowtv.tv_sec + n - 1; do { if (sigwinched) { sigwinched = 0; @@ -232,7 +234,7 @@ main(int argc, char *argv[]) fprintf(stderr, "grdc terminated by signal %d\n", sigtermed); exit(1); } - } while(--n); + } while (n == 0 || nowtv.tv_sec < endtv.tv_sec); standend(); clear(); refresh(); |