Perl select return “bad file descriptor” error

前端 未结 1 1065
生来不讨喜
生来不讨喜 2021-01-24 02:22

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          


        
1条回答
  •  有刺的猬
    2021-01-24 02:47

      $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.

    0 讨论(0)
提交回复
热议问题