Some time ago I had problems with $SIG{WINCH}
because I loaded two module which were both using $SIG{WINCH}
Problems with $SIG{WINCH} when using it in a module.
Now I have tried to reconstruct this case but this time I put in one module the $SIG{WINCH}
within a subroutine.
use warnings;
use strict;
package My_Package;
use Exporter 'import';
our @EXPORT = qw(choose);
sub choose {
# ...
my $size_changed;
local $SIG{WINCH} = sub { $size_changed = 1; }; # edit: added "local"
while ( 1 ) {
my $c = getch();
if ( $size_changed ) {
write_screen();
$size_changed = 0;
next;
}
# ...
}
}
Now it looks like it is working.
Am I save if I localize $SIG{WINCH}
this way or did I forget something when reconstructing?