nodejs / nodejs/node

File descriptor 0 might not get closed when used in file stream

未关闭
#57,905 4 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

fs
主要语言
JavaScript
星标
122k
派生
37.4k
平均合并
4 天 3 小时
30 天内合并 PR
272

描述

Just from reading the code it seems the file descriptor 0 is not closed for streams.

https://github.com/nodejs/node/blob/e61937b82cbaec758cceeb08876dd51f976b23c2/lib/internal/fs/streams.js#L117-L127

I have not run any tests to confirm that, but the check in code if (!stream.fd) looks rather clear and does not work for fd 0. The _close function actually sets null, so more null-like check should be there:

https://github.com/nodejs/node/blob/e61937b82cbaec758cceeb08876dd51f976b23c2/lib/internal/fs/streams.js#L129-L134

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

首先阅读 lib/internal/fs/streams.js 中链接的部分,尤其是第 117-134 行,并追踪 stream 的文件描述符是如何被检查和清除的。确认描述符 0 的行为,并为报告的案例添加覆盖。完成标准是:描述符 0 被关闭,同时不会导致其他 stream 清理出现回归。

由索引模型根据 Issue 内容生成。

评估

技术栈
javascript
领域
operating-systems
Issue 类型
缺陷
难度
2/5
预计耗时
1-3 小时
活跃度
冷清
描述清晰度
描述清楚
新手友好度
55/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。