From: Mischa POSLAWSKY Date: Thu, 12 Sep 2019 16:56:15 +0000 (+0200) Subject: show statistics on SIGQUIT X-Git-Tag: v1.06~7 X-Git-Url: http://git.shiar.nl/barcat.git/commitdiff_plain/a0ff197f92a8630d87509509ad635c8f194fa29b show statistics on SIGQUIT Misuse this signal as it's the best suited on linux being usually bound to ctrl-\. The same behaviour can also be seen in at least ping from iputils. GNU dd offers similar progress on SIGUSR1, but this cannot be bound by stty. --- diff --git a/barcat b/barcat index bdfde47..650e406 100755 --- a/barcat +++ b/barcat @@ -87,6 +87,7 @@ $opt{'value-length'} = 1 if $opt{unmodified}; my (@lines, @values, @order); +$SIG{QUIT} = \&show_stat; $SIG{ALRM} = sub { show_lines(); alarm $opt{interval} if defined $opt{interval} and $opt{interval} > 0; @@ -220,7 +221,7 @@ say '' if $opt{spark}; } show_lines(); -if ($opt{stat}) { +sub show_stat { if ($opt{hidemin} or $opt{hidemax}) { $opt{hidemin} ||= 1; $opt{hidemax} ||= @lines; @@ -238,6 +239,7 @@ if ($opt{stat}) { } say ''; } +show_stat() if $opt{stat}; __END__ =encoding utf8