From https://github.com/mysticatea/npm-run-all/issues/24
process.stdin getter stops a program in the following case:
child_process.exec)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.
/cc @nodejs/platform-windows
smells like it might be related to https://github.com/nodejs/node/issues/5384
https://github.com/nodejs/node/issues/5384#issuecomment-219984590 seems to be fixed on v6.2.0.
But this is still an issue.
Simpler testcase: node.exe test.js in Git Bash.
This happens because the call to pNtQueryInformationFile hangs here.
Might be a Windows bug?
Pinging @orangemocha @piscisaureus @saghul
@seishun I'm not sure what happens in that case TBH. Git Bash is a MSYS based environment AFAIK, so I wonder if it will load that super-old CRT MSYS was based on.
@saghul Do you mean C runtime library? That's irrelevant since NtQueryInformationFile is a Win32 function, right?
Also Git Bash is based on MSYS2 nowadays, which is a recent fork of Cygwin.
Yes, it's a Win32 API function, but stdin / out / err are CRT fds, so I guess the problem comes somewhere around there.
This is related to https://github.com/nodejs/node/issues/3006 .
In Git Bash, with node.exe test.js I get the issue described here (PIPE), but with node test.js it works fine (TTY). However, winpty works well either way:
winpty node.exe test.js
winpty node test.js
In Git Bash, with node.exe test.js I get the issue described here (PIPE), but with node test.js it works fine (TTY).
In case anyone is wondering, this is because Git Bash aliases node to winpty node.exe. According to @dscho, they have to read fewer bug reports this way (see https://github.com/git-for-windows/git/issues/738#issuecomment-213424855).
Hah, and instead we get to deal with the fallout? Nice!
Am I right in concluding that this is an environmental issue not directly caused by or under control of node? If yes, I move to close.
Hah, and instead we get to deal with the fallout? Nice!
Sorry for that.
Am I right in concluding that this is an environmental issue not directly caused by or under control of node?
Yes, the problem is caused by MinTTY using the tty emulation of MSYS2's runtime (which is a portable version of the Cygwin runtime), and node expecting to talk to a real Win32 Console (which the winpty bridge provides and synchronizes to the MSYS2 tty).
If yes, I move to close.
FWIW I agree.
Thanks for chiming in. Okay, I'll go ahead and close.
Hey guys, I'm not as technical as you, but I followed all the links here and in other issues and have read it all (didn't understand much, since my programming skill-set is only client-side), and I didn't fully get what is the status of the git bash colors issue?
should I download any new version of anything? because I'm already on latest GIT (windows port) so should I try Node7? I'm not sure what to do to see colors on my Git Bash :(
@yairEO I don't think this issue was related to colours on Git bash. What exactly is the issue you're seeing?
This issue is a problem with Git Bash not with node, the workaround is to run node your_file.js instead of node.exe your_file.js.
@gibfahn - thank you, I followed the maze of issues pointing to one another until I ended up here, at the bottom of the trail, so I thought it wouldn't hurt asking, but luckily I was helped in another thread
@yairEO in the future you're very welcome to ask questions at https://github.com/nodejs/help
I think that this should help:
alias -p npm="winpty npm.exe"
Run it in git-bash once and you can use 'npm test'
Actually you should run this instead and restart git-bash:
echo alias -p npm=\"winpty npm.exe\" >> ~/.bashrc
@ltvan does this really fix the problem with the script described in this ticket?
If so, would it not make more sense to add npm handling to https://github.com/git-for-windows/build-extra/blob/db6871f1f5490670456f2869387c7e9fcb6b5d9c/git-extra/aliases.sh#L13 ?
It does work in my environment. Adding to git-extra is good so.
However, if you run through gulp or grunt, the winpty gulp won't work.
In opposition to workaround given by @gibfahn above I had to use node.exe instead of node to get some script processing content redirected on stdin, so my workaround is the opposite to his suggestion.
didn't work:
node ./processor.js < input > result
did work:
node.exe ./processor.js < input > result
Most helpful comment
Hah, and instead we get to deal with the fallout? Nice!
Am I right in concluding that this is an environmental issue not directly caused by or under control of node? If yes, I move to close.