修复drop fd时,文件描述符引用不为0的问题 (#382)

This commit is contained in:
LoGin 2023-09-16 16:16:43 +08:00 committed by GitHub
parent de71ec259c
commit 71474bc682
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -503,11 +503,7 @@ impl FileDescriptorVec {
return Err(SystemError::EBADF);
}
let f = self.get_file_by_fd(fd);
if f.is_none() {
// 如果文件描述符不存在,报错
return Err(SystemError::EBADF);
}
self.get_file_by_fd(fd).ok_or(SystemError::EBADF)?;
// 把文件描述符数组对应位置设置为空
let file = self.fds[fd as usize].take().unwrap();