-
Notifications
You must be signed in to change notification settings - Fork 245
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
feat(dotnet,java): kernel process inherits host's STDERR #2248
Changes from all commits
6d2be36
0bbb249
480e69f
cec02a5
9fc6542
588182c
3aeb3b8
840d4cb
0bae44e
aaf1252
7ef36ba
bbcce77
83c07f1
3b123a9
6b64d20
a624312
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,4 +28,4 @@ void IDisposable.Dispose() | |
JsiiTypeAttributeBase.Reset(); | ||
} | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
using System; | ||
using System.Threading.Tasks; | ||
|
||
namespace Amazon.JSII.Runtime.Services | ||
{ | ||
|
@@ -10,19 +9,14 @@ internal sealed class Runtime : IRuntime | |
public Runtime(INodeProcess nodeProcess) | ||
{ | ||
_nodeProcess = nodeProcess ?? throw new ArgumentNullException(nameof(nodeProcess)); | ||
if (Environment.GetEnvironmentVariable("JSII_DEBUG") != null) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What functionality do we lose here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Previously, |
||
{ | ||
Task.Run(() => RedirectStandardError()); | ||
} | ||
} | ||
|
||
public string ReadResponse() | ||
{ | ||
var response = _nodeProcess.StandardOutput.ReadLine(); | ||
if (string.IsNullOrEmpty(response)) | ||
{ | ||
var errorMessage = _nodeProcess.StandardError.ReadToEnd(); | ||
throw new JsiiException("Child process exited unexpectedly: " + errorMessage); | ||
throw new JsiiException("Child process exited unexpectedly!"); | ||
} | ||
|
||
return response; | ||
|
@@ -43,13 +37,5 @@ public void WriteRequest(string request) | |
_nodeProcess.StandardInput.WriteLine(request); | ||
_nodeProcess.StandardInput.Flush(); | ||
} | ||
|
||
private void RedirectStandardError() | ||
{ | ||
while (true) | ||
{ | ||
Console.Error.WriteLine(_nodeProcess.StandardError.ReadLine()); | ||
} | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are these not needed anymore ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
StandardInput
,StandardOutput
andStandardError
are actually directly obtained from properties of theProcess
instance... When we callDispose()
on the process, it naturally disposes of all resources it owns, including those streams.Additionally,
Dispose()
might abruptly terminate the stream, possibly without having flushed some buffered data. CallingClose()
instead tends to ensure the buffer is flushed out before the close happens, so thenode
process gets the signal we are trying to send.