Processes created using spawn with a pipe have no /dev/stdin
未关闭
还没有人认领这个 Issue。
child_process
- 主要语言
- JavaScript
- 星标
- 122k
- 派生
- 37.4k
- 平均合并
- 4 天 3 小时
- 30 天内合并 PR
- 272
描述
- Version: v8.9.4
- Platform: Linux 4.9.0-6-amd64 #1 SMP Debian 4.9.82-1+deb9u3 (2018-03-02) x86_64 GNU/Linux
- Subsystem: child_process
The code below fails with cat: /dev/stdin: No such device or address.
const {spawn} = require('child_process');
const proc = spawn('cat', ['/dev/stdin'], {stdio: ['pipe', process.stdout, process.stderr]});
Apparently Node spawns sub processes in a way that there is no /dev/stdin allocated.
I think this is a NodeJS bug - on UNIX, a sub process should be able to open /dev/stdin if there is a stdin for it. The following Go program for example works perfectly fine:
func main() {
cmd := exec.Command("cat", "/dev/stdin")
cmd.Stderr = os.Stderr
cmd.Stdout = os.Stdout
stdin, _ := cmd.StdinPipe()
go func() {
stdin.Write([]byte("hello cat!\n"))
stdin.Close()
}()
cmd.Run()
}
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从 Node.js 的 child_process 子系统入手,在 Linux 上重现所提供的 spawn('cat', ['/dev/stdin'], ...) 示例,并将其与 Go 示例进行比较。当预期的 Unix stdin 行为得到确立,且报告的失败已由回归测试覆盖时,即视为完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- javascript, linux, node.js
- 领域
- backend, operating-systems
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 45/100