Problems with $SIG{WINCH} when using it in a module

≡放荡痞女 提交于 2019-12-06 15:32:36

I think I've found the reason: apart from this module I load a second module which does use $SIG{WINCH} too.
When I don't load the second module the choose subroutine works as expected.

Why are you modifying a variable then waiting for it in an infinite loop?

Wouldn't be better if you call that sub from signal handler directly?

$SIG{WINCH} = sub { print STDERR "WINCH!\n";choose(); };

This handler is in your module main secion, it is executed in complie time not execution time and only if you using use not require.

Maybe this is works in a module

local $size_changed;
BEGIN{
   $SIG{WINCH} = sub { $size_changed = 1; };
}

Just a guess: try to use Perl::Unsafe::Signals.

use Perl::Unsafe::Signals;
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!