Skip to content

Commit

Permalink
Merge pull request #144 from pjlsergeant/clean-child-processes
Browse files Browse the repository at this point in the history
Reap completed forked processes
  • Loading branch information
ehuelsmann authored Aug 20, 2019
2 parents a9d9b19 + d7cc395 commit e5055ab
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion lib/TAP/Parser/Iterator/PherkinStream.pm
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,20 @@ use base 'TAP::Parser::Iterator::Stream';


sub _initialize {
my ($self, $fh, $pherkin) = @_;
my ($self, $fh, $pherkin, $child_pid) = @_;

$self->{pherkin} = $pherkin;
$self->{child_pid} = $child_pid;
return $self->SUPER::_initialize($fh);
}

sub _finish {
my $self = shift;

$self->{pherkin}->_post_run();
if ($self->{child_pid}) {
waitpid $self->{child_pid}, 0; # reap child process
}
return $self->SUPER::_finish(@_);
}

Expand Down
2 changes: 1 addition & 1 deletion lib/TAP/Parser/SourceHandler/Feature.pm
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ sub make_iterator {
my $pid = fork;
if ($pid) {
close $output_fh;
return TAP::Parser::Iterator::PherkinStream->new($input_fh, $pherkin);
return TAP::Parser::Iterator::PherkinStream->new($input_fh, $pherkin, $pid);
}

close $input_fh;
Expand Down

0 comments on commit e5055ab

Please sign in to comment.