From 7bd55cb2331f0cd2ccb94adc5e3c46fb35dc47fa Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Wed, 31 Oct 2018 17:57:26 -0500 Subject: [PATCH] Protect IOC.pm against errors These can happen if the IOC dies prematurely. --- modules/database/src/tools/EPICS/IOC.pm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/database/src/tools/EPICS/IOC.pm b/modules/database/src/tools/EPICS/IOC.pm index cd46b1e59..eebb0da66 100644 --- a/modules/database/src/tools/EPICS/IOC.pm +++ b/modules/database/src/tools/EPICS/IOC.pm @@ -268,6 +268,7 @@ sub _geterrors { while ($self->{select}->can_read(0.01)) { sysread $self->{stderr}, my $errbuf, 1024; push @errors, split m/\n/, $self->{errbuf} . $errbuf, -1; + last unless @errors; $self->{errbuf} = pop @errors; } return @errors; @@ -311,7 +312,7 @@ sub cmd { } push @response, $self->_getlines($term); - pop @response if $response[-1] =~ $term; + pop @response if @response and $response[-1] =~ $term; my @errors = $self->_geterrors; if (scalar @errors && $self->{debug}) {