Description
- Version: master
- Platform: all
- Subsystem: child_process
A noted problem pattern is broken data flow when i) spawning OS commands that predate Node.js and that do not expect their stdios to be non-blocking. ii) Composite IPC that involves more than one Node process in the process chain.
The underlying issue is the mixed mode I/O in a number of variations based on number of parent-child combo that is possible.
While many of these can be mitigated by studying the I/O characteristics of parent and child and crafting a suitable IPC that works, inability to (programatically) control the blocking behavior (flow mode) of the stdio channel causes usability issues.
Proposals:
Node parent -> non-Node child
Node parent - Node child
- exec family functions to receive option to control the blocking behavior of child stdios (new option)
- adjust the child stdios accordingly, while retaining parent side of pipes non-blocking
- convert stdout and stderr to nonblocking prior to exit to help drain the buffered chunks (revisit process: flush stdout/stderr upon
process.exit()
#6773)
Node parent - non-Node child -> Node grand child
Node parent - non-Node child -> non-Node grand child
- restore stdio characteristics on exit (already being worked upon in src: restore stdio on program exit #17737)
- convert stdout and stderr to nonblocking prior to exit to help drain the buffered chunks
references:
truncated stdout on porcess exit: #19218 #784 #6456 #6379
pre-fabricated duplex streams for IPC: #16553 #15714 #13542
inconsistent IPC with process chain: #9413
unexpected flow mode for stdio: #14752 #18446 #19838