-
Notifications
You must be signed in to change notification settings - Fork 30.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
tty: stdio properties are undefined inside exec() child #2333
Comments
When the new process is created, the diff --git a/src/node.js b/src/node.js
index af66b17..87121bc 100644
--- a/src/node.js
+++ b/src/node.js
@@ -717,6 +717,12 @@
stdin._handle.readStop();
});
+ stdin.isTTY = true;
+ stdin.isRaw = false;
+ stdin.setRawMode = function setRawMode(mode) {
+ throw new Error('Not a Raw device');
+ };
+
return stdin;
});
|
Doing this unconditionally worries me a bit. For the isTTY case, I wonder why the code path in |
The |
Hmm, I don't see the |
@silverwind Actually, I tested the changes and it is working fine. Shall I submit a PR with the code in this issue as a test? |
Go ahead, it's good to have a PR so we can run CI anyways. |
@silverwind I am not making changes for the |
I'm primarily after |
When a child process is created, the `stdin` will not have `isTTY`, `isRaw` and `setRawMode` properties. Because, `uv_guess_handle` in `guessHandleType` call returns `PIPE` for fd 0. So, we create a `net.Socket` and return. But normally it will return `TTY` and we create `tty.ReadStream` and return where all those properties are properly set. This path explicitly sets the above mentioned properties on the returned socket object. Fixes: nodejs#2333 PR-URL: nodejs#2336
Mmm #2160? |
@sabrehagen is it possible that your script was being piped to or was being called by |
Been thinking about this some more. The docs are pretty clear that these
I think I'll just leave it at that. A possible change to introduce these properties would be a breaking change if done right, and I don't think it's worth doing so, it doesn't really solve any issues. |
But stdin will be inconsistent when we exec, I am not sure if that is okay |
True. I don't understand completely what |
I believe the same problem should be with spawn as well. I'll check that today |
I gave up on doing the rework of your PR because there'd be a tiny change of breakage when someone does The issue I was trying to solve is this: var child = exec("iojs child.js", function (err, stdout, stderr) {
process.stdout.write(stdout);
});
process.stdin.pipe(child.stdin); After this pipe is made, the child's stdin should upgrade to a ReadStream instance (and have these properties defined). Ideally, this should happen before the child executes its first line of code. |
@silverwind wrote:
The child is a separate node process, right? Is there realistically even a way to guarantee order like that when there are two separate processes? |
FYI
In other words, by executing a shell in the // parent.js
const spawn = require('child_process').spawn;
spawn('NODE_ENV=production node ./child.js', { shell: true, stdio: 'inherit' }); // child.js
const chalk = require('chalk');
process.stdout.write(`${chalk.magenta('child')}\n`);
|
I'm wondering if there's really anything to do here other than simply expand the documentation to account for this. |
I'm wondering if this is intentional or a bug:
parent.js
child.js
output:
ref: sindresorhus/grunt-shell#95 raineorshine/npm-check-updates#119
The text was updated successfully, but these errors were encountered: