From 2b59fc70aaa48d0a77e015e165604f9b9f1a39d8 Mon Sep 17 00:00:00 2001 From: Ed J Date: Tue, 1 Oct 2024 10:51:20 +0000 Subject: [PATCH] add default SIG{TERM,INT,QUIT,HUP} handler to close more gracefully --- CHANGES | 2 ++ lib/PDL/Graphics/Gnuplot.pm | 10 ++++------ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/CHANGES b/CHANGES index 1233102..93da1b4 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,5 @@ +- add default SIG{TERM,INT,QUIT,HUP} handler to close more gracefully + 2.030 2024-09-29 - require PDL version that has raster2fits; previously didn't require one with t_raster2fits which test used diff --git a/lib/PDL/Graphics/Gnuplot.pm b/lib/PDL/Graphics/Gnuplot.pm index 2c8ef14..b18186b 100644 --- a/lib/PDL/Graphics/Gnuplot.pm +++ b/lib/PDL/Graphics/Gnuplot.pm @@ -67,7 +67,6 @@ # each option. Since this mechanism is near at hand, we use it even # for routines (such as read_polygon) that could and would use # PDL::Options in other circumstances. -# =encoding UTF-8 @@ -2076,6 +2075,8 @@ our @EXPORT_OK = qw( ); our @EXPORT = qw(gpwin gplot greplot greset grestart); +$SIG{TERM} = $SIG{INT} = $SIG{QUIT} = $SIG{HUP} = sub { die; }; + # when testing plots with binary i/o, this is the unit of test data my $testdataunit_binary = "........"; # 8 bytes - length of an IEEE double @@ -2392,13 +2393,13 @@ FOO # Default the 'persist' option to 0, so that interactive windows behave nicely unless # asked to stay. - if(exists($termTab->{$terminal}->{opt}->[0]->{persist}) and + if (exists($termTab->{$terminal}{opt}[0]{persist}) and !defined($termOptions->{persist}) ) { $termOptions->{persist} = 0; } # Default the 'dashed' option to 1. - if(exists($termTab->{$terminal}->{opt}->[0]->{dashed}) and + if (exists($termTab->{$terminal}{opt}[0]{dashed}) and !defined($termOptions->{dashed}) ) { $termOptions->{dashed} = 1; } @@ -2454,7 +2455,6 @@ sub DESTROY _killGnuplot($this); } - =pod =head2 close @@ -7305,10 +7305,8 @@ sub _killGnuplot { $z = waitpid($goner, 0); alarm(0); - } - unless($z == $goner) { # If for some reason it didn't die, fire and forget. kill 'KILL', $goner;