If a child process dies while the parent is attempting to read status
information from the child, the pipe connecting the two will be cleaned
up. The parent mustn't attempt to read from the dead pipe or it will
result in a bad file descriptor error, culminating in a high-cpu
infinite loop on the parent (Listener) process.
Signed-off-by: Bill Erickson <berick@esilibrary.com>
Signed-off-by: Thomas Berezansky <tsbere@mvlc.org>
Signed-off-by: Jason Stephenson <jstephenson@mvlc.org>
return unless @{$self->{active_list}};
- my $read_set = IO::Select->new;
- $read_set->add($_->{pipe_to_child}) for @{$self->{active_list}};
-
my @pids;
while (1) {
# if can_read or sysread is interrupted while bloking, go back and
# wait again until we have at least 1 free child
+ # refresh the read_set handles in case we lost a child in the previous iteration
+ my $read_set = IO::Select->new;
+ $read_set->add($_->{pipe_to_child}) for @{$self->{active_list}};
+
if(my @handles = $read_set->can_read(($block) ? undef : 0)) {
my $pid = '';
for my $pipe (@handles) {