From d8ec46178ea8788397f1df28b37b3b11601f04e1 Mon Sep 17 00:00:00 2001 From: Yves Orton Date: Thu, 14 Apr 2022 14:44:06 +0200 Subject: op/magic.t - make $SIG{ALRM} local test deal with inherited IGNORE'd signal Signal ignores can be set up by a parent process and the child process will inherit them. So in some situations when we test $SIG{ALRM} might be "IGNORE" and not undef. So instead of just expecting undef, check what it was before the localization, and then check it is still that value afterwards. I found this while running make test via rebase --exec, something like this reduction (from Matthew Horsfall): $ git rebase --exec='perl -le"print \$SIG{ALRM}"' HEAD~1 IGNORE A similar case for a different signal would be this example (from Leon Timmermans): $ nohup perl -E 'say $SIG{HUP}' 2>/dev/null | cat IGNORE --- t/op/magic.t | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 't/op/magic.t') diff --git a/t/op/magic.t b/t/op/magic.t index 442735df49..d879406f58 100644 --- a/t/op/magic.t +++ b/t/op/magic.t @@ -932,10 +932,14 @@ SKIP: { } } +# in some situations $SIG{ALRM} might be 'IGNORE', eg: +# git rebase --exec='perl -e "print \$SIG{ALRM}" && git co -f' HEAD~2 +# will print out 'IGNORE' +my $sig_alarm_expect= $SIG{ALRM}; { local %SIG = (%SIG, ALRM => sub {}) }; -is $SIG{ALRM}, undef; +is $SIG{ALRM}, $sig_alarm_expect, '$SIG{ALRM} is as expected'; # test case-insignificance of %ENV (these tests must be enabled only # when perl is compiled with -DENV_IS_CASELESS) -- cgit v1.2.1