reset SIGINT after first ignoral
authorMischa POSLAWSKY <perl@shiar.org>
Mon, 9 Sep 2019 16:51:10 +0000 (18:51 +0200)
committerMischa POSLAWSKY <perl@shiar.org>
Mon, 9 Sep 2019 22:37:53 +0000 (00:37 +0200)
Ensure subsequent signals will break any unexpected hangs.

barcat

diff --git a/barcat b/barcat
index 723c7da3a3f6e4d0045b41413ef9e06f1d2cc87d..c1e1d079ce40d75a5cf04a5a68fd499d222a2cd7 100755 (executable)
--- a/barcat
+++ b/barcat
@@ -77,7 +77,10 @@ if (defined $opt{interval}) {
        } or warn $@, "Expect slowdown with large datasets!\n";
 }
 
-$SIG{INT} = 'IGNORE';  # continue after assumed eof
+$SIG{INT} = sub {
+       $SIG{INT} = 'DEFAULT';  # reset for subsequent attempts
+       'IGNORE' # continue after assumed eof
+};
 
 my $valmatch = qr/$opt{anchor} ( \h* -? [0-9]* \.? [0-9]+ (?: e[+-]?[0-9]+ )? |)/x;
 while (readline) {