Skip to content
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

stderr? #55

Closed
jamesrwhite opened this issue Jan 7, 2014 · 2 comments
Closed

stderr? #55

jamesrwhite opened this issue Jan 7, 2014 · 2 comments

Comments

@jamesrwhite
Copy link

Excuse my ignorance if there is an obvious reason for this but why does trying to get the output from stderr like so:

child.stderr.on('data', function(data) {});

result in https://github.com/chjj/pty.js/blob/master/lib/pty.js#L289

Is it simply not possible to get the output from stderr or has it just not been implemented?

Thanks :)

@chjj
Copy link
Owner

chjj commented Jan 8, 2014

Terminals don't work this way. A pty fd is, conceptually speaking, basically just a socket. There is no stdin/stdout/stderr. The parent process creates a master/slave fd pair, the parent keeps the master pty fd, and the forked child keeps the slave fd - the child then dup2's the slave fd onto stdin/stdout/stderr, so there's no way to tell stdout/stderr apart when you read from the master fd. (You can see openpty and forkpty implemented in src/unix/pty.cc for a better look at how this works).

I included .stdout and .stderr properties on the Terminal object just because that's what everyone is used to from the child_process module. People might be inclined to use them out of habit, but they're purely aesthetic and don't serve any real purpose.

@chjj chjj closed this as completed Jan 8, 2014
@jamesrwhite
Copy link
Author

Ah I see, that makes a lot more sense now. Thank you for clarifying :)

ddm pushed a commit to ddm/pty.js that referenced this issue Nov 8, 2017
ddm pushed a commit to ddm/pty.js that referenced this issue Nov 8, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants