Skip to content

process.stdin never returns with using Git Bash for Windows #5620

@mysticatea

Description

@mysticatea
  • Version: v4.4.0 and v5.7.1
  • Platform: Windows 64bit

From mysticatea/npm-run-all#24

process.stdin getter stops a program in the following case:

  • On Git Bash of Git for Windows (MINGW64)
  • Executing cmd.exe (e.g. child_process.exec)
  • Inheriting stdin.

This is a repro steps:

$ cmd /C="node test.js"
"use strict";

const name = process.argv[2] || "parent";

console.log("before stdin:", name, process.binding('tty_wrap').guessHandleType(0));
process.stdin;
console.log("after stdin:", name);

if (process.argv[2] !== "child") {
    require("child_process").spawn(
        process.argv[0],
        [process.argv[1], "child"],
        {stdio: "inherit"}
    );
}

The results of above:

cmd.exe OK

C:\Users\t-nagashima.AD\Documents\GitHub\WebDevolopment\Pizzeria-ES2015>cmd /C=node test.js
before stdin: parent TTY
after stdin: parent
before stdin: child TTY
after stdin: child

PowerShell OK

PS C:\Users\t-nagashima.AD\Documents\GitHub\WebDevolopment\Pizzeria-ES2015> cmd /C="node test.js"
before stdin: parent TTY
after stdin: parent
before stdin: child TTY
after stdin: child

Git Shell of GitHub for Windows OK

C:\Users\t-nagashima.AD\Documents\GitHub\WebDevolopment\Pizzeria-ES2015 [master +1 ~1 -0 !]> cmd /C="node test.js"
before stdin: parent TTY
after stdin: parent
before stdin: child TTY
after stdin: child

Git Bash of Git for Windows Wrong

t-nagashima@T-NAGASHIMA4 MINGW64 /c/Users/t-nagashima.AD/Documents/GitHub/WebDevolopment/Pizzeria-ES2015 (master)
$ cmd /C="node test.js"
before stdin: parent PIPE
after stdin: parent
before stdin: child PIPE

The program stops at process.stdin, then "after stdin: child" has never printed.
If I types Enter Key, the program resumes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    child_processIssues and PRs related to the child_process subsystem.processIssues and PRs related to the 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