summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorStuart Henderson <sthen@cvs.openbsd.org>2020-05-04 12:13:10 +0000
committerStuart Henderson <sthen@cvs.openbsd.org>2020-05-04 12:13:10 +0000
commit14ec1b444dbd75ae5d9e5495bf1a4f45c8df8b74 (patch)
treefe8265a9ee1cee092df528578bd32a0e1e67593c /usr.bin
parent792ce25af93bbd1f65632e31ce93b6ea08a3b80e (diff)
tcpbench: display stats on SIGINFO, not just at exit. ok tb@ procter@ deraadt@
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/tcpbench/tcpbench.113
-rw-r--r--usr.bin/tcpbench/tcpbench.c13
2 files changed, 21 insertions, 5 deletions
diff --git a/usr.bin/tcpbench/tcpbench.1 b/usr.bin/tcpbench/tcpbench.1
index 9580f8c09b2..9f7a7063971 100644
--- a/usr.bin/tcpbench/tcpbench.1
+++ b/usr.bin/tcpbench/tcpbench.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: tcpbench.1,v 1.27 2020/05/02 22:00:29 procter Exp $
+.\" $OpenBSD: tcpbench.1,v 1.28 2020/05/04 12:13:09 sthen Exp $
.\"
.\" Copyright (c) 2008 Damien Miller <djm@mindrot.org>
.\"
@@ -14,7 +14,7 @@
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd $Mdocdate: May 2 2020 $
+.Dd $Mdocdate: May 4 2020 $
.Dt TCPBENCH 1
.Os
.Sh NAME
@@ -82,6 +82,15 @@ Its accuracy may be increased by decreasing the
.Ar interval .
The summary bytes and duration cover the interval from transfer start
to process exit.
+The summary information can also be displayed while
+.Nm
+is running by sending it a
+.Dv SIGINFO
+signal (see the
+.Cm status
+argument of
+.Xr stty 1
+for more information).
.Pp
The options are as follows:
.Bl -tag -width Ds
diff --git a/usr.bin/tcpbench/tcpbench.c b/usr.bin/tcpbench/tcpbench.c
index c181d878a48..18da6be0653 100644
--- a/usr.bin/tcpbench/tcpbench.c
+++ b/usr.bin/tcpbench/tcpbench.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tcpbench.c,v 1.62 2020/05/02 22:00:29 procter Exp $ */
+/* $OpenBSD: tcpbench.c,v 1.63 2020/05/04 12:13:09 sthen Exp $ */
/*
* Copyright (c) 2008 Damien Miller <djm@mindrot.org>
@@ -213,6 +213,10 @@ signal_handler(int sig, short event, void *bula)
* signal handler rules don't apply, libevent decouples for us
*/
switch (sig) {
+ case SIGINFO:
+ printf("\n");
+ wrapup(-1);
+ break;
case SIGINT:
printf("\n");
wrapup(0);
@@ -1109,7 +1113,8 @@ wrapup(int err)
summary_display();
}
- exit(err);
+ if (err != -1)
+ exit(err);
}
int
@@ -1126,7 +1131,7 @@ main(int argc, char **argv)
int family = PF_UNSPEC;
struct nlist nl[] = { { "_tcbtable" }, { "" } };
const char *host = NULL, *port = DEFAULT_PORT, *srcbind = NULL;
- struct event ev_sigint, ev_sigterm, ev_sighup, ev_progtimer;
+ struct event ev_sigint, ev_sigterm, ev_sighup, ev_siginfo, ev_progtimer;
struct sockaddr_un sock_un;
/* Init world */
@@ -1362,9 +1367,11 @@ main(int argc, char **argv)
signal_set(&ev_sigterm, SIGTERM, signal_handler, NULL);
signal_set(&ev_sighup, SIGHUP, signal_handler, NULL);
signal_set(&ev_sigint, SIGINT, signal_handler, NULL);
+ signal_set(&ev_siginfo, SIGINFO, signal_handler, NULL);
signal_add(&ev_sigint, NULL);
signal_add(&ev_sigterm, NULL);
signal_add(&ev_sighup, NULL);
+ signal_add(&ev_siginfo, NULL);
signal(SIGPIPE, SIG_IGN);
if (UDP_MODE) {