Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(89)

Unified Diff: runtime/bin/process_impl.dart

Issue 11343009: Get rid of 'close' on process. It is very easy to use incorrectly and cut off data from your stream… (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comment. Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/bin/process.dart ('k') | tests/standalone/io/dart_std_io_pipe_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/process_impl.dart
diff --git a/runtime/bin/process_impl.dart b/runtime/bin/process_impl.dart
index 48670e441efc342e100409b33090133b2fce7cab..ab8dfd080f98c11c7a261e9f6b8eaf6020d48d30 100644
--- a/runtime/bin/process_impl.dart
+++ b/runtime/bin/process_impl.dart
@@ -73,7 +73,6 @@ class _Process extends NativeFieldWrapperClass1 implements Process {
_out = new _Socket._internalWriteOnly(); // stdin going to process.
_err = new _Socket._internalReadOnly(); // stderr coming from process.
_exitHandler = new _Socket._internalReadOnly();
- _closed = false;
_ended = false;
_started = false;
_onExit = null;
@@ -148,7 +147,10 @@ class _Process extends NativeFieldWrapperClass1 implements Process {
_exitHandler,
status);
if (!success) {
- close();
+ _in.close();
+ _out.close();
+ _err.close();
+ _exitHandler.close();
completer.completeException(
new ProcessException(status._errorMessage, status._errorCode));
return;
@@ -185,6 +187,7 @@ class _Process extends NativeFieldWrapperClass1 implements Process {
if (_onExit !== null) {
_onExit(exitCode(exitDataBuffer));
}
+ _out.close();
}
exitDataRead += _exitHandler.inputStream.readInto(
@@ -208,23 +211,14 @@ class _Process extends NativeFieldWrapperClass1 implements Process {
_ProcessStartStatus status) native "Process_Start";
InputStream get stdout {
- if (_closed) {
- throw new ProcessException("Process closed");
- }
return _in.inputStream;
}
InputStream get stderr {
- if (_closed) {
- throw new ProcessException("Process closed");
- }
return _err.inputStream;
}
OutputStream get stdin {
- if (_closed) {
- throw new ProcessException("Process closed");
- }
return _out.outputStream;
}
@@ -240,21 +234,7 @@ class _Process extends NativeFieldWrapperClass1 implements Process {
bool _kill(Process p, int signal) native "Process_Kill";
- void close() {
- if (_closed) {
- throw new ProcessException("Process closed");
- }
- _in.close();
- _out.close();
- _err.close();
- _exitHandler.close();
- _closed = true;
- }
-
void set onExit(void callback(int exitCode)) {
- if (_closed) {
- throw new ProcessException("Process closed");
- }
if (_ended) {
throw new ProcessException("Process killed");
}
@@ -270,7 +250,6 @@ class _Process extends NativeFieldWrapperClass1 implements Process {
_Socket _out;
_Socket _err;
Socket _exitHandler;
- bool _closed;
bool _ended;
bool _started;
Function _onExit;
« no previous file with comments | « runtime/bin/process.dart ('k') | tests/standalone/io/dart_std_io_pipe_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698