# num_cores * 2.
my $parallel = undef;
my @displays = ();
-my @childpids = ();
my $result = GetOptions(
"coverage-testing" => \$coverage_testing,
if (@displays == 0) {
my ($displays, $pids) = start_xdummy($parallel);
@displays = @$displays;
- @childpids = @$pids;
+
+ push our @CLEANUP, sub { kill(15, $_) for @$pids };
}
# connect to all displays for two reasons:
close $log;
-kill(15, $_) for @childpids;
+cleanup();
exit 0;
}
}
+sub cleanup {
+ $_->() for our @CLEANUP;
+}
+
+# must be in a begin block because we C<exit 0> above
+BEGIN { $SIG{$_} = \&cleanup for qw(INT TERM QUIT KILL) }
+
__END__
=head1 NAME