Open
Description
- Version:
13.11.0
(tried on8.3.0
too, same result) - Platform: Linux
- Subsystem: Ubuntu
19.10
What steps will reproduce the bug?
foo.c
#include <stdio.h>
int main() {
char str[100];
gets(str);
puts(str);
return 0;
}
Compile it:
$ gcc -o foo foo.c
index.js
:
const { spawn } = require('child_process')
const child = spawn('./foo')
process.stdin.pipe(child.stdin)
child.on('exit', () => {
console.log('done')
process.stdin.unpipe(child.stdin)
})
Launch index.js
:
$ node index.js
input
done
After entering some input
, the child process exits and done
is printed. However the main process does not exit (although it should). It looks like process.stdin
has a left handle. After entering newline again on stdin
, the process now exits.
How often does it reproduce?
Always
What is the expected behavior?
See above.
What do you see instead?
See above.