Skip to content

Commit

Permalink
Rearrange EPICS::IOC->close() to be more robust
Browse files Browse the repository at this point in the history
  • Loading branch information
anjohnson committed Jan 1, 2020
1 parent aad8a96 commit 81df1b2
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions modules/database/src/tools/EPICS/IOC.pm
Expand Up @@ -363,21 +363,25 @@ sub close {
unless $self->started;

close $self->{stdin};
$self->{stdin} = gensym;

my @response = $self->_getlines; # No terminator
close $self->{stdout};
$self->{stdout} = gensym;

$self->{select}->remove($self->{stderr});
close $self->{stderr};

my $pid = $self->{pid};

# Reset these before we call waitpid in case of timeout
$self->{pid} = undef;
$self->{stdin} = gensym;
$self->{stdout} = gensym;
$self->{stderr} = gensym;

if ($^O ne 'MSWin32') {
kill 'TERM', $self->{pid};
waitpid $self->{pid}, 0;
kill 'TERM', $pid;
waitpid $pid, 0;
}
$self->{pid} = undef;

return @response;
}
Expand Down

0 comments on commit 81df1b2

Please sign in to comment.