diff options
author | Yves Orton <demerphq@gmail.com> | 2022-04-14 14:44:06 +0200 |
---|---|---|
committer | Karl Williamson <khw@cpan.org> | 2022-04-19 05:41:19 -0600 |
commit | d8ec46178ea8788397f1df28b37b3b11601f04e1 (patch) | |
tree | 4d6bb08ee5deda7a95cb3755e0dfbfe781f0ec7c /t/op/magic.t | |
parent | 707277569cdff3602ff0533ccf258de95e37195d (diff) | |
download | perl-d8ec46178ea8788397f1df28b37b3b11601f04e1.tar.gz |
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
Diffstat (limited to 't/op/magic.t')
-rw-r--r-- | t/op/magic.t | 6 |
1 files changed, 5 insertions, 1 deletions
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) |