``` @@ -87,8 +88,8 @@ public class FilenoUtil { // It appears to happen for openpty, and in theory could happen for any IO call that produces // a new descriptor. if (fd != null && !fd.ch.isOpen() && !isFake(fileno)) { - FileStat stat = posix.allocateStat(); - if (posix.fstat(fileno, stat) >= 0) { + int ret = posix.fcntl(fileno, Fcntl.F_GETFL); + if (ret >= 0) { // found ChannelFD is closed, but actual fileno is open; clear it. filenoMap.remove(fileno); fd = null; ```