Chromium Code Reviews| 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 /** | 5 /** |
| 6 * [Process] is used to start new processes using the static | 6 * [Process] is used to start new processes using the static |
| 7 * [start] and [run] methods. | 7 * [start] and [run] methods. |
| 8 */ | 8 */ |
| 9 class Process { | 9 class Process { |
| 10 /** | 10 /** |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 84 */ | 84 */ |
| 85 abstract void set onExit(void callback(int exitCode)); | 85 abstract void set onExit(void callback(int exitCode)); |
| 86 | 86 |
| 87 /** | 87 /** |
| 88 * Set an error handler which gets invoked if an operation on the process | 88 * Set an error handler which gets invoked if an operation on the process |
| 89 * fails. | 89 * fails. |
| 90 */ | 90 */ |
| 91 abstract void set onError(void callback(e)); | 91 abstract void set onError(void callback(e)); |
| 92 | 92 |
| 93 /** | 93 /** |
| 94 * Kills the process. When the process terminates as a result of | 94 * On Windows, [kill] kills the process, ignoring the [signal] flag. On |
| 95 * calling [kill] [onExit] is called. If the kill operation fails, | 95 * Posix systems, [kill] sends [signal] to the process. Depending on the |
| 96 * signal giving, it'll have different meanings. The defualt [signal] to | |
| 97 * send is [:ProcessSignal.SIGTERM:]. When the process terminates as a result | |
| 98 * of calling [kill] [onExit] is called. If the kill operation fails, | |
| 96 * [onError] is called. | 99 * [onError] is called. |
| 97 */ | 100 */ |
| 98 abstract void kill(); | 101 abstract void kill([ProcessSignal signal]); |
| 99 | 102 |
| 100 /** | 103 /** |
| 101 * Terminates the streams of a process. [close] must be called on a | 104 * Terminates the streams of a process. [close] must be called on a |
| 102 * process to free the system resources associated with it if not all | 105 * process to free the system resources associated with it if not all |
| 103 * data on the stdout and stderr streams have been read. Usually, | 106 * data on the stdout and stderr streams have been read. Usually, |
| 104 * close should be called in [onExit], but care must be taken to actually | 107 * close should be called in [onExit], but care must be taken to actually |
| 105 * wait on the stderr and stdout streams to close if all data is required. | 108 * wait on the stderr and stdout streams to close if all data is required. |
| 106 * Once a process has been closed it can no longer be killed and [onExit] | 109 * Once a process has been closed it can no longer be killed and [onExit] |
| 107 * is detached so the application is not notified of process termination. | 110 * is detached so the application is not notified of process termination. |
| 108 */ | 111 */ |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 171 * Provides the environment variables for the process. If not set | 174 * Provides the environment variables for the process. If not set |
| 172 * the environment of the parent process is inherited. | 175 * the environment of the parent process is inherited. |
| 173 * | 176 * |
| 174 * Currently, only ASCII environment variables are supported and | 177 * Currently, only ASCII environment variables are supported and |
| 175 * errors are likely to occur if an environment variables with | 178 * errors are likely to occur if an environment variables with |
| 176 * code-points outside the ASCII range is passed in. | 179 * code-points outside the ASCII range is passed in. |
| 177 */ | 180 */ |
| 178 Map<String, String> environment; | 181 Map<String, String> environment; |
| 179 } | 182 } |
| 180 | 183 |
| 184 /** | |
| 185 * On Posix systems, [ProcessSignal]s is used to send a specific signal | |
|
Mads Ager (google)
2012/06/12 09:13:44
is -> are or remove the 's' after [ProcessSignal]
Anders Johnsen
2012/06/12 09:21:04
Done.
| |
| 186 * on kill, see [:Process.kill:]. | |
| 187 */ | |
| 188 class ProcessSignal { | |
| 189 static final ProcessSignal SIGHUP = const ProcessSignal._signal(1); | |
| 190 static final ProcessSignal SIGINT = const ProcessSignal._signal(2); | |
| 191 static final ProcessSignal SIGQUIT = const ProcessSignal._signal(3); | |
| 192 static final ProcessSignal SIGILL = const ProcessSignal._signal(4); | |
| 193 static final ProcessSignal SIGTRAP = const ProcessSignal._signal(5); | |
| 194 static final ProcessSignal SIGABRT = const ProcessSignal._signal(6); | |
| 195 static final ProcessSignal SIGBUS = const ProcessSignal._signal(7); | |
| 196 static final ProcessSignal SIGFPE = const ProcessSignal._signal(8); | |
| 197 static final ProcessSignal SIGKILL = const ProcessSignal._signal(9); | |
| 198 static final ProcessSignal SIGUSR1 = const ProcessSignal._signal(10); | |
| 199 static final ProcessSignal SIGSEGV = const ProcessSignal._signal(11); | |
| 200 static final ProcessSignal SIGUSR2 = const ProcessSignal._signal(12); | |
| 201 static final ProcessSignal SIGPIPE = const ProcessSignal._signal(13); | |
| 202 static final ProcessSignal SIGALRM = const ProcessSignal._signal(14); | |
| 203 static final ProcessSignal SIGTERM = const ProcessSignal._signal(15); | |
| 204 static final ProcessSignal SIGCHLD = const ProcessSignal._signal(17); | |
| 205 static final ProcessSignal SIGCONT = const ProcessSignal._signal(18); | |
| 206 static final ProcessSignal SIGSTOP = const ProcessSignal._signal(19); | |
| 207 static final ProcessSignal SIGTSTP = const ProcessSignal._signal(20); | |
| 208 static final ProcessSignal SIGTTIN = const ProcessSignal._signal(21); | |
| 209 static final ProcessSignal SIGTTOU = const ProcessSignal._signal(22); | |
| 210 static final ProcessSignal SIGURG = const ProcessSignal._signal(23); | |
| 211 static final ProcessSignal SIGXCPU = const ProcessSignal._signal(24); | |
| 212 static final ProcessSignal SIGXFSZ = const ProcessSignal._signal(25); | |
| 213 static final ProcessSignal SIGVTALRM = const ProcessSignal._signal(26); | |
| 214 static final ProcessSignal SIGPROF = const ProcessSignal._signal(27); | |
| 215 static final ProcessSignal SIGPOLL = const ProcessSignal._signal(29); | |
| 216 static final ProcessSignal SIGSYS = const ProcessSignal._signal(31); | |
| 217 | |
| 218 const ProcessSignal._signal(int this._signalNumber); | |
| 219 final int _signalNumber; | |
| 220 } | |
| 221 | |
| 181 | 222 |
| 182 class ProcessException implements Exception { | 223 class ProcessException implements Exception { |
| 183 const ProcessException([String this.message, int this.errorCode = 0]); | 224 const ProcessException([String this.message, int this.errorCode = 0]); |
| 184 String toString() => "ProcessException: $message ($errorCode)"; | 225 String toString() => "ProcessException: $message ($errorCode)"; |
| 185 | 226 |
| 186 /** | 227 /** |
| 187 * Contains the system message for the process exception if any. | 228 * Contains the system message for the process exception if any. |
| 188 */ | 229 */ |
| 189 final String message; | 230 final String message; |
| 190 | 231 |
| 191 /** | 232 /** |
| 192 * Contains the OS error code for the process exception if any. | 233 * Contains the OS error code for the process exception if any. |
| 193 */ | 234 */ |
| 194 final int errorCode; | 235 final int errorCode; |
| 195 } | 236 } |
| OLD | NEW |