> On 4/05/2020, at 9:30 AM, Stuart Henderson <s...@spacehopper.org> wrote:
>
> On 2020/05/04 09:23, Richard Procter wrote:
>> I like it.
>>
>> Assuming a mention in tcpbench.1 - ok procter
>
> ok like this? text stolen from ping.
the server has an small edge case: it refuses to display stats
that don’t exist, e.g. if no data transfer has occured. Though
it will indicate receipt of SIGINFO by printing ‘\n’.
I see ping(1) in the same circumstance omits the stats line alone.
But that’s perhaps something for a later commit. I don’t think it
warrants mention in the man page.
ok procter
> Index: tcpbench.1
> ===================================================================
> RCS file: /cvs/src/usr.bin/tcpbench/tcpbench.1,v
> retrieving revision 1.27
> diff -u -p -r1.27 tcpbench.1
> --- tcpbench.1 2 May 2020 22:00:29 -0000 1.27
> +++ tcpbench.1 3 May 2020 21:29:22 -0000
> @@ -82,6 +82,15 @@ Its accuracy may be increased by decreas
> .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
> Index: tcpbench.c
> ===================================================================
> RCS file: /cvs/src/usr.bin/tcpbench/tcpbench.c,v
> retrieving revision 1.62
> diff -u -p -r1.62 tcpbench.c
> --- tcpbench.c 2 May 2020 22:00:29 -0000 1.62
> +++ tcpbench.c 3 May 2020 21:29:22 -0000
> @@ -213,6 +213,10 @@ signal_handler(int sig, short event, voi
> * 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) {
>