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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 ${Strings.join(args, " ")}'); |
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(1000 * timeout, (t) { | 71 timer = new Timer(new Duration(seconds: timeout), () { |
72 timer = null; | 72 timer = null; |
73 process.kill(); | 73 process.kill(); |
74 }); | 74 }); |
75 | 75 |
76 process.onExit = (exitCode) { | 76 process.onExit = (exitCode) { |
77 if (timer != null) { | 77 if (timer != null) { |
78 timer.cancel(); | 78 timer.cancel(); |
79 } | 79 } |
80 process.close(); | 80 process.close(); |
81 if (completer != null) { | 81 if (completer != null) { |
(...skipping 97 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 |