I am trying to implement inter process communication using pipes and the select
command. Here is a first try:
use warnings;
use strict;
use feature
$fh->close();
$sel->remove($fh);
You must first remove the file descriptor from the select and then close it. Once it is closed it is no longer valid (that is fileno($fh)
will return undef) and cannot be removed. And if cannot be removed select will still try to select on this (invalid) file descriptor, causing EBADF.