Skip to content

Windows: child_process.spawn leaving orphaned processes around when running processes in an sh shell #34830

@ManiacDC

Description

@ManiacDC
  • Version: 12.14.1
  • Platform: Windows 10
  • Subsystem: x64 1909

What steps will reproduce the bug?

Please see this reproduction utility & its readme:
https://github.com/ManiacDC/npm-sh-issue

Basically, launching node from an sh shell, then running tsc from a new shell (sh -c) from within node, will leave orphaned processes behind when ctrl-c is hit in the terminal.

For reference, stdio is set to pipe, windowsHide is set to false, and shell is set to true. If stdio is set to 'inherit', this issue does not occur.

How often does it reproduce? Is there a required condition?

On demand. stdio must NOT be set to inherit. The shell launching node must be "sh" or "bash", the shell being used to launch tsc must be "sh" or "bash".

What is the expected behavior?

All child processes should close.

What do you see instead?

The child processes are orphaned and remain running until killed in the task manager (since they run tsc -w, which runs until terminated).

Additional information

This was originally discovered via lerna/lerna#2284 , reported on sindresorhus/execa#433, and narrowed down to this. I think this may actually be an issue with git-for-windows/msys2's implementation of sh & bash, but I'm not sure.

Metadata

Metadata

Assignees

No one assigned

    Labels

    child_processIssues and PRs related to the child_process subsystem.windowsIssues and PRs related to the Windows platform.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions