diff options
author | 2014-11-19 03:27:45 +0000 | |
---|---|---|
committer | 2014-11-19 03:27:45 +0000 | |
commit | dc238ad5f4ab22ac9e6fef5a869f2b18f14909dd (patch) | |
tree | b24ba297c0adaf385ff6e6e989d1e37c4380b3d8 | |
parent | Escape sequences terminate high-level macro names, and when doing so, (diff) | |
download | wireguard-openbsd-dc238ad5f4ab22ac9e6fef5a869f2b18f14909dd.tar.xz wireguard-openbsd-dc238ad5f4ab22ac9e6fef5a869f2b18f14909dd.zip |
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(); |