Fix `.pipe()` with the `stdio` option and orphaned destination subprocesses
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Piping forces the destination's `stdin` option to `'pipe'`, which cannot be combined with the `stdio` option. That made `to: 'fd3'` and higher unreachable, since those need `stdio`. Piping now leaves `stdin` alone when `stdio` is set. Also, the destination subprocess is spawned before the `to` option is validated. If validation then failed, the destination kept running, e.g. waiting for its `stdin` forever, which prevented the current process from exiting. Its error also became an unhandled rejection, which crashes the current process. A destination spawned by Execa is now terminated, and its error is handled. A destination subprocess passed by the user is left running, since the user still controls it.
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
5 files+85 added−6 removed
- tests:+49 added−0 removed
- other:+36 added−6 removed