Processes created using spawn with a pipe have no /dev/stdin
Open
Nobody has claimed this yet.
child_process
- Dominant language
- JavaScript
- Stars
- 122k
- Forks
- 37.3k
- Avg merge
- 4d 2h
- Merged PRs (30d)
- 283
Description
- 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()
}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in Node.js's child_process subsystem and reproduce the supplied spawn('cat', ['/dev/stdin'], ...) example on Linux, comparing it with the Go example. Done means the expected Unix stdin behavior is established and the reported failure is covered by a regression test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, linux, node.js
- Domain
- backend, operating-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100