Running tests in background

Felipe Gasper felipe at felipegasper.com
Tue Jun 8 15:19:45 CEST 2021


> On Jun 8, 2021, at 2:37 AM, Marc Lehmann <schmorp at schmorp.de> wrote:
> 
> On Mon, Jun 07, 2021 at 12:50:01PM -0400, Felipe Gasper <felipe at felipegasper.com> wrote:
>> 	Would you consider using SIGUSR1 instead of SIGINT in the AE test suite?
> 
> If there is a good reason to...
> 
>> 	We recently switched our test suite to run tests in a shell background. This caused AE’s test suite to fail on 02_signal.t, which we eventually realized was because the shell sets SIGINT to ignore, which Perl represents by saying that $SIG{INT} is 'IGNORE', which causes AnyEvent->signal() to be a no-op.
> 
> I will have to think about that. Of course, changing to SIGUSR1 does
> nothing but work around the intricacies of your test environment, and
> using USR1 will not realyl do anything, as that will then break with
> another person's test script. Maybe AnyEvent should treat ignored signals
> as it does default signals, but probably not.
> 
> Does the problem still perisst when you also instakl Async::Interrupt?

No, actually.

In fact, another pain point of mine with AE--the fact that a %SIG value of 'DEFAULT' is treated differently from undef/empty--also goes away with that module.

Is the intent that AnyEvent behave (as much as reasonably possible) the same with or without Async::Interrupt? If so--and assuming that Async::Interrupt’s behaviour is considered the more ideal--that would seem to make a case for treating 'DEFAULT' and 'IGNORE' %SIG values the same as undef/empty.

Notably: the problem also goes away when I switch to EV as the backend rather than AnyEvent::Loop.

A bit more alarmingly, though, EV and AE::Loop/Async::Interrupt will both clobber existing, non-default/ignore signal handlers, which plain AE::Loop will not do:

# EV:
perl -Mstrict -w -MAnyEvent -e '$SIG{USR1} = sub {}; my $cv = AE::cv(); my $s = AE::signal( q/USR1/, $cv ); kill q/USR1/, $$; $cv->recv()'

# Async::Interrupt:
perl -Mstrict -w -MAnyEvent::Loop -e '$SIG{USR1} = sub {}; my $cv = AE::cv(); my $s = AE::signal( q/USR1/, $cv ); kill q/USR1/, $$; $cv->recv()'

# Hangs:
perl -Mstrict -w -MAnyEvent::Loop -e '$SIG{USR1} = sub {}; my $cv = AE::cv(); $AnyEvent::Base::HAVE_ASYNC_INTERRUPT = 0; my $s = AE::signal( q/USR1/, $cv ); kill q/USR1/, $$; $cv->recv()'


> 
>> 	Since the use of signals in those tests is specific to the application, it seems like SIGUSR1 would make more sense--and it would also allow the tests to run without modification when backgrounded.
> 
> Arguably, SIGINT is correct as there is nothing application specific to
> SIGINT.

What I meant is: if it’s more common for shells and the like to defeat SIGINT than SIGUSR1, then using SIGUSR1 (or USR2?) in the tests would make the tests less dependent on their environment.

-F


More information about the anyevent mailing list