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 /** Exit the Dart VM process with the given [status] code. */ | 5 /** Exit the Dart VM process with the given [status] code. */ |
6 void exit(int status) { | 6 void exit(int status) { |
7 if (status is !int) { | 7 if (status is !int) { |
8 throw new IllegalArgumentException("int status expected"); | 8 throw new IllegalArgumentException("int status expected"); |
9 } | 9 } |
10 _exit(status); | 10 _exit(status); |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 */ | 92 */ |
93 abstract void set onExit(void callback(int exitCode)); | 93 abstract void set onExit(void callback(int exitCode)); |
94 | 94 |
95 /** | 95 /** |
96 * Set an error handler which gets invoked if an operation on the process | 96 * Set an error handler which gets invoked if an operation on the process |
97 * fails. | 97 * fails. |
98 */ | 98 */ |
99 abstract void set onError(void callback(e)); | 99 abstract void set onError(void callback(e)); |
100 | 100 |
101 /** | 101 /** |
102 * On Windows, [kill] kills the process, ignoring the [signal] flag. On | 102 * On Windows, [kill] kills the process, ignoring the [signal] |
103 * Posix systems, [kill] sends [signal] to the process. Depending on the | 103 * flag. On Posix systems, [kill] sends [signal] to the |
104 * signal giving, it'll have different meanings. The default [signal] to | 104 * process. Depending on the signal giving, it'll have different |
105 * send is [:ProcessSignal.SIGTERM:]. When the process terminates as a result | 105 * meanings. When the process terminates as a result of calling |
106 * of calling [kill] [onExit] is called. If the kill operation fails, | 106 * [kill] [onExit] is called. If the kill operation fails, [onError] |
107 * [onError] is called. | 107 * is called. |
108 */ | 108 */ |
109 abstract void kill([ProcessSignal signal]); | 109 abstract void kill([ProcessSignal signal = ProcessSignal.SIGTERM]); |
110 | 110 |
111 /** | 111 /** |
112 * Terminates the streams of a process. [close] must be called on a | 112 * Terminates the streams of a process. [close] must be called on a |
113 * process to free the system resources associated with it if not all | 113 * process to free the system resources associated with it if not all |
114 * data on the stdout and stderr streams have been read. Usually, | 114 * data on the stdout and stderr streams have been read. Usually, |
115 * close should be called in [onExit], but care must be taken to actually | 115 * close should be called in [onExit], but care must be taken to actually |
116 * wait on the stderr and stdout streams to close if all data is required. | 116 * wait on the stderr and stdout streams to close if all data is required. |
117 * Once a process has been closed it can no longer be killed and [onExit] | 117 * Once a process has been closed it can no longer be killed and [onExit] |
118 * is detached so the application is not notified of process termination. | 118 * is detached so the application is not notified of process termination. |
119 */ | 119 */ |
120 abstract void close(); | 120 abstract void close(); |
121 } | 121 } |
122 | 122 |
123 | 123 |
124 /** | 124 /** |
125 * [ProcessResult] represents the result of running a non-interactive | 125 * [ProcessResult] represents the result of running a non-interactive |
126 * process started with [:Process.run:]. | 126 * process started with [:Process.run:]. |
127 */ | 127 */ |
128 interface ProcessResult { | 128 abstract class ProcessResult { |
129 /** | 129 /** |
130 * Exit code for the process. | 130 * Exit code for the process. |
131 */ | 131 */ |
132 int get exitCode; | 132 int get exitCode; |
133 | 133 |
134 /** | 134 /** |
135 * Standard output from the process as a string. | 135 * Standard output from the process as a string. |
136 */ | 136 */ |
137 String get stdout; | 137 String get stdout; |
138 | 138 |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 static const ProcessSignal SIGPROF = const ProcessSignal._signal(27); | 222 static const ProcessSignal SIGPROF = const ProcessSignal._signal(27); |
223 static const ProcessSignal SIGPOLL = const ProcessSignal._signal(29); | 223 static const ProcessSignal SIGPOLL = const ProcessSignal._signal(29); |
224 static const ProcessSignal SIGSYS = const ProcessSignal._signal(31); | 224 static const ProcessSignal SIGSYS = const ProcessSignal._signal(31); |
225 | 225 |
226 const ProcessSignal._signal(int this._signalNumber); | 226 const ProcessSignal._signal(int this._signalNumber); |
227 final int _signalNumber; | 227 final int _signalNumber; |
228 } | 228 } |
229 | 229 |
230 | 230 |
231 class ProcessException implements Exception { | 231 class ProcessException implements Exception { |
232 const ProcessException([String this.message, int this.errorCode = 0]); | 232 const ProcessException([String this.message = "", int this.errorCode = 0]); |
233 String toString() => "ProcessException: $message ($errorCode)"; | 233 String toString() => "ProcessException: $message ($errorCode)"; |
234 | 234 |
235 /** | 235 /** |
236 * Contains the system message for the process exception if any. | 236 * Contains the system message for the process exception if any. |
237 */ | 237 */ |
238 final String message; | 238 final String message; |
239 | 239 |
240 /** | 240 /** |
241 * Contains the OS error code for the process exception if any. | 241 * Contains the OS error code for the process exception if any. |
242 */ | 242 */ |
243 final int errorCode; | 243 final int errorCode; |
244 } | 244 } |
OLD | NEW |