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

Unified Diff: utils/pub/io.dart

Issue 11470030: Work around issue 7218 in Pub. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Bug fixes. Created 8 years 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 | « utils/pub/curl_client.dart ('k') | utils/tests/pub/test_pub.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: utils/pub/io.dart
diff --git a/utils/pub/io.dart b/utils/pub/io.dart
index 1990aa28c9e4ec7f6a40ca5d36c9ab0ce917d1fb..0e2fe332b232ec2c98537afc94cd349be98fd59a 100644
--- a/utils/pub/io.dart
+++ b/utils/pub/io.dart
@@ -646,7 +646,30 @@ Future<PubProcessResult> runProcess(String executable, List<String> args,
/// the inherited variables.
Future<Process> startProcess(String executable, List<String> args,
{workingDir, Map<String, String> environment}) =>
- _doProcess(Process.start, executable, args, workingDir, environment);
+ _doProcess(Process.start, executable, args, workingDir, environment)
+ .transform((process) => new _WrappedProcess(process));
+
+/// A wrapper around [Process] that buffers the stdout and stderr to avoid
+/// running into issue 7218.
+class _WrappedProcess implements Process {
+ final Process _process;
+ final InputStream stderr;
+ final InputStream stdout;
+
+ OutputStream get stdin => _process.stdin;
+
+ void set onExit(void callback(int exitCode)) {
+ _process.onExit = callback;
+ }
+
+ _WrappedProcess(Process process)
+ : _process = process,
+ stderr = wrapInputStream(process.stderr),
+ stdout = wrapInputStream(process.stdout);
+
+ bool kill([ProcessSignal signal = ProcessSignal.SIGTERM]) =>
+ _process.kill(signal);
+}
/// Calls [fn] with appropriately modified arguments. [fn] should have the same
/// signature as [Process.start], except that the returned [Future] may have a
@@ -819,7 +842,7 @@ Future<bool> extractTarGz(InputStream stream, destination) {
}
var completer = new Completer<int>();
- var processFuture = Process.start("tar",
+ var processFuture = startProcess("tar",
["--extract", "--gunzip", "--directory", destination]);
processFuture.then((process) {
process.onExit = completer.complete;
« no previous file with comments | « utils/pub/curl_client.dart ('k') | utils/tests/pub/test_pub.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698