| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 part of pipeline; | 5 part of pipeline; |
| 6 | 6 |
| 7 List stdout, stderr, log; | 7 List stdout, stderr, log; |
| 8 var replyPort; | 8 var replyPort; |
| 9 int _procId = 1; | 9 int _procId = 1; |
| 10 Map _procs = {}; | 10 Map _procs = {}; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 * to the [Process] will be put in a map with key [procId]; in this case | 54 * to the [Process] will be put in a map with key [procId]; in this case |
| 55 * the process can be terminated later by calling [stopProcess] and | 55 * the process can be terminated later by calling [stopProcess] and |
| 56 * passing in the [procId]. | 56 * passing in the [procId]. |
| 57 * [outputMonitor] is an optional function that will be called back with each | 57 * [outputMonitor] is an optional function that will be called back with each |
| 58 * line of output from the process. | 58 * line of output from the process. |
| 59 * Returns a [Future] for when the process terminates. | 59 * Returns a [Future] for when the process terminates. |
| 60 */ | 60 */ |
| 61 Future _processHelper(String command, List<String> args, | 61 Future _processHelper(String command, List<String> args, |
| 62 [int timeout = 300, int procId = 0, Function outputMonitor]) { | 62 [int timeout = 300, int procId = 0, Function outputMonitor]) { |
| 63 var completer = procId == 0 ? new Completer() : null; | 63 var completer = procId == 0 ? new Completer() : null; |
| 64 log.add('Running $command ${Strings.join(args, " ")}'); | 64 log.add('Running $command ${args.join(" ")}'); |
| 65 var timer = null; | 65 var timer = null; |
| 66 var stdoutHandler, stderrHandler; | 66 var stdoutHandler, stderrHandler; |
| 67 var processFuture = Process.start(command, args); | 67 var processFuture = Process.start(command, args); |
| 68 processFuture.then((process) { | 68 processFuture.then((process) { |
| 69 _procs[procId] = process; | 69 _procs[procId] = process; |
| 70 | 70 |
| 71 timer = new Timer(new Duration(seconds: timeout), () { | 71 timer = new Timer(new Duration(seconds: timeout), () { |
| 72 timer = null; | 72 timer = null; |
| 73 process.kill(); | 73 process.kill(); |
| 74 }); | 74 }); |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 stderr = new List(); | 179 stderr = new List(); |
| 180 log = new List(); | 180 log = new List(); |
| 181 } | 181 } |
| 182 | 182 |
| 183 void completePipeline([exitCode = 0]) { | 183 void completePipeline([exitCode = 0]) { |
| 184 replyPort.send([stdout, stderr, log, exitCode]); | 184 replyPort.send([stdout, stderr, log, exitCode]); |
| 185 } | 185 } |
| 186 | 186 |
| 187 /** Utility function to log diagnostic messages. */ | 187 /** Utility function to log diagnostic messages. */ |
| 188 void logMessage(msg) => log.add(msg); | 188 void logMessage(msg) => log.add(msg); |
| OLD | NEW |