Handling of SIGINT
Andy Armstrong
andy at hexten.net
Thu Feb 19 17:18:58 GMT 2009
On 19 Feb 2009, at 17:16, Alex Vandiver wrote:
> Heya,
> Test::HTTP::Server::Simple sets up a $SIG{INT} handler to try to tear
> down the HTTP server it starts, which works fine if you hand the test
> script directly to perl. But if you run it with prove, prove gets hit
> by the SIGINT, dies, and summarily kills off the test script with no
> warning, which leaves the HTTP server hanging around, and generally
> makes a mess of things.
Why isn't the SIGINT going to the test script?
> What would people think of the following patch?
> It has the side-effect of having prove print out a summary after the
> ^C,
> which doesn't seem too wrong to me offhand.
> - Alex
>
> Index: lib/TAP/Parser/Iterator/Process.pm
> ===================================================================
> --- lib/TAP/Parser/Iterator/Process.pm (revision 1269)
> +++ lib/TAP/Parser/Iterator/Process.pm (working copy)
> @@ -123,6 +123,11 @@
> my $merge = delete $args->{merge};
> my ( $pid, $err, $sel );
>
> + # Pass along any interrupts to the child
> + $SIG{INT} = sub {
> + kill INT => $self->{pid};
> + };
> +
> if ( my $setup = delete $args->{setup} ) {
> $setup->(@command);
> }
>
> --
> Networking -- only one letter away from not working
>
> _______________________________________________
> tapx-dev mailing list
> tapx-dev at hexten.net
> http://www.hexten.net/mailman/listinfo/tapx-dev
> cpan: http://search.cpan.org/dist/TAP-Parser/
> bugs: http://rt.cpan.org/Public/Dist/Display.html?Name=TAP-Parser
--
Andy Armstrong, Hexten
More information about the tapx-dev
mailing list