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

Expose an stderr stream #71

Closed
aashidham opened this issue Apr 2, 2017 · 12 comments
Closed

Expose an stderr stream #71

aashidham opened this issue Apr 2, 2017 · 12 comments
Labels

Comments

@aashidham
Copy link

how do I access the stderr of a process spawned with this module?

@Tyriar
Copy link
Member

Tyriar commented Apr 3, 2017

You can't differentiate stderr/stdout that is passed through a pty AFAIK, see http://stackoverflow.com/a/16839544/1156119

@Tyriar Tyriar closed this as completed Apr 3, 2017
@Tyriar Tyriar added the question label Apr 3, 2017
@aashidham
Copy link
Author

aashidham commented Apr 3, 2017 via email

@Tyriar
Copy link
Member

Tyriar commented Apr 3, 2017

A pty is a pseudo tty and I think they behave the same in this regard.

@aashidham
Copy link
Author

aashidham commented Apr 3, 2017 via email

@aashidham
Copy link
Author

aashidham commented Apr 3, 2017 via email

@Tyriar
Copy link
Member

Tyriar commented Apr 3, 2017

@jerch
Copy link
Collaborator

jerch commented Apr 4, 2017

@Tyriar To be able to reroute the STDERR might be a useful enhancement. Not sure if it is worth the trouble, since it will deal only with the first process on slave end (bash etc.) and might lead to weird behavior (some programs tend to behave differently if they find a blocking buffering fd for any of the standard channels).
To get this done, the module needs some OS level pipe abstraction to be exported to JS land.

@Tyriar
Copy link
Member

Tyriar commented Apr 4, 2017

No plans to invest in this at the moment, the fact that it might lead to some weird behavior is another reason for not implementing 😃

@stevenvachon
Copy link

stevenvachon commented Jul 13, 2017

So, we can never get the error message to find out why the child process crashed?

@Tyriar
Copy link
Member

Tyriar commented Jul 14, 2017

I'm guessing we would need to do something like this to support pulling stderr https://reviews.llvm.org/D15073

@Tyriar Tyriar reopened this Jul 14, 2017
@Tyriar Tyriar added enhancement help wanted Issues identified as good community contribution opportunities and removed question labels Jul 14, 2017
@Tyriar Tyriar changed the title why is stderr undefined? Expose an stderr stream Jul 14, 2017
@jerch
Copy link
Collaborator

jerch commented Jul 14, 2017

@stevenvachon A process behind a pseudo terminal is not to be expected to have other "channels" than the bidirectional terminal fd, which handles all the input and output. This simple setup dates back to teletype writers (tty) in the 60s even before the UNIX gurus came up with the STDIN, STDOUT, STDERR process interface idea. Therefore the low level forkpty does not give any option to set up another side channel to handle STDERR elsewhere. This does not mean it is impossible, but needs several considerations before trying to implement it:

  1. good unix citizens behave differently for tty standard IO channels than for buffered normal pipe channels - Does the extra STDERR channel need to be its own pty device or will a simple pipe fd do the trick? This can lead to weird behavior of the child process if not done right.
  2. What about child-children? How to get their error messages? A session leader (typically a shell) would spawn own children with dupes of the controlling terminal fd for STDIN, STDOUT, STDERR unless you explicitly tell it to do otherwise (e.g. redirects in a shell script). This might be a dead end right after the first child process here (unless you undermine the shell's fork & exec calls).
  3. circumvent the forkpty limitation by doing your own fd dupes

The real show stopper is 2. imho, it is simply not much of a use, if you can't propagate the additional fd to the sub children.

@Tyriar Yeah it is possible with that, it is basically setting up an additional fd before exec, kinda implementing 3. I see a use case for this if you need to run a single process behind a pty (omitting the shell subchildren problem in 2.) 1. still needs to be tested carefully, which heavily depends on the subprocesses themselves (one might test with isatty against STDERR, others might not). Side note here - node-pty is kinda broken atm for a single subprocess due to #85

@Tyriar Tyriar added invalid and removed enhancement help wanted Issues identified as good community contribution opportunities labels Jul 28, 2017
@Tyriar
Copy link
Member

Tyriar commented Jul 28, 2017

Closing this as designed, no plans to do this extra work when it will only apply to the parent shell.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants