diff options
author | 2019-01-06 18:27:14 +0000 | |
---|---|---|
committer | 2019-01-06 18:27:14 +0000 | |
commit | 8ca82b000914eb1e6f45d22092c9358df4233247 (patch) | |
tree | b8da65f8f4f3b743c5376410f851e38c6c761a36 | |
parent | grammar fix from chohag jtan com; (diff) | |
download | wireguard-openbsd-8ca82b000914eb1e6f45d22092c9358df4233247.tar.xz wireguard-openbsd-8ca82b000914eb1e6f45d22092c9358df4233247.zip |
allow q to exit the program.
ok cheloha deraadt schwarze
-rw-r--r-- | games/grdc/grdc.6 | 9 | ||||
-rw-r--r-- | games/grdc/grdc.c | 20 |
2 files changed, 23 insertions, 6 deletions
diff --git a/games/grdc/grdc.6 b/games/grdc/grdc.6 index 4dc02df3947..6822a96acf1 100644 --- a/games/grdc/grdc.6 +++ b/games/grdc/grdc.6 @@ -1,8 +1,8 @@ -.\" $OpenBSD: grdc.6,v 1.10 2014/11/17 22:14:25 schwarze Exp $ +.\" $OpenBSD: grdc.6,v 1.11 2019/01/06 18:27:14 tedu Exp $ .\" .\" Copyright 2002 Amos Shapir. Public domain. .\" -.Dd $Mdocdate: November 17 2014 $ +.Dd $Mdocdate: January 6 2019 $ .Dt GRDC 6 .Os .Sh NAME @@ -26,7 +26,10 @@ The optional flag makes digits scroll as they change. If the terminal is too slow to keep up, .Nm -will skip seconds. +skips seconds. +Pressing the +.Sq q +exits the program. .Sh AUTHORS .An -nosplit .An Amos Shapir , diff --git a/games/grdc/grdc.c b/games/grdc/grdc.c index 8af4e730236..ea2d3408b92 100644 --- a/games/grdc/grdc.c +++ b/games/grdc/grdc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: grdc.c,v 1.29 2018/08/23 06:25:01 mestre Exp $ */ +/* $OpenBSD: grdc.c,v 1.30 2019/01/06 18:27:14 tedu Exp $ */ /* * * Copyright 2002 Amos Shapir. Public domain. @@ -18,7 +18,9 @@ #include <limits.h> #include <signal.h> #include <stdlib.h> +#include <stdio.h> #include <time.h> +#include <poll.h> #include <unistd.h> #define XLENGTH 58 @@ -59,10 +61,11 @@ int main(int argc, char *argv[]) { long t, a; - int i, j, s, k; + int i, j, s, k, rv; int scrol; int n = 0; struct timespec delay, end; + struct pollfd pfd; const char *errstr; long scroldelay = 50000000; int xbase; @@ -106,6 +109,9 @@ main(int argc, char *argv[]) signal(SIGWINCH, sigresize); signal(SIGCONT, sigresize); /* for resizes during suspend */ + pfd.fd = STDIN_FILENO; + pfd.events = POLLIN; + cbreak(); noecho(); @@ -224,7 +230,15 @@ main(int argc, char *argv[]) /* want scrolling to END on the second */ if (scrol && !wintoosmall) delay.tv_nsec -= 5 * scroldelay; - nanosleep(&delay, NULL); + rv = ppoll(&pfd, 1, &delay, NULL); + if (rv == 1) { + char q = 0; + read(STDIN_FILENO, &q, 1); + if (q == 'q') { + n = 1; + end.tv_sec = now.tv_sec; + } + } now.tv_sec++; if (sigtermed) { |