OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 dart.io; | 5 part of dart.io; |
6 | 6 |
7 // TODO(ager): The only reason for this class is that we | 7 // TODO(ager): The only reason for this class is that we |
8 // cannot patch a top-level at this point. | 8 // cannot patch a top-level at this point. |
9 class _ProcessUtils { | 9 class _ProcessUtils { |
10 external static void _exit(int status); | 10 external static void _exit(int status); |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 */ | 90 */ |
91 abstract class Process { | 91 abstract class Process { |
92 /** | 92 /** |
93 * Returns a [:Future:] which completes with the exit code of the process | 93 * Returns a [:Future:] which completes with the exit code of the process |
94 * when the process completes. | 94 * when the process completes. |
95 * | 95 * |
96 * The handling of exit codes is platform specific. | 96 * The handling of exit codes is platform specific. |
97 * | 97 * |
98 * On Linux and Mac a normal exit code will be a positive value in | 98 * On Linux and Mac a normal exit code will be a positive value in |
99 * the range [0..255]. If the process was terminated due to a signal | 99 * the range [0..255]. If the process was terminated due to a signal |
100 * the exit code will be a negative value in the range [-255..0[, | 100 * the exit code will be a negative value in the range [-255..-1], |
101 * where the absolute value of the exit code is the signal | 101 * where the absolute value of the exit code is the signal |
102 * number. For example, if a process crashes due to a segmentation | 102 * number. For example, if a process crashes due to a segmentation |
103 * violation the exit code will be -11, as the signal SIGSEGV has the | 103 * violation the exit code will be -11, as the signal SIGSEGV has the |
104 * number 11. | 104 * number 11. |
105 * | 105 * |
106 * On Windows a process can report any 32-bit value as an exit | 106 * On Windows a process can report any 32-bit value as an exit |
107 * code. When returning the exit code this exit code is turned into | 107 * code. When returning the exit code this exit code is turned into |
108 * a signed value. Some special values are used to report | 108 * a signed value. Some special values are used to report |
109 * termination due to some system event. E.g. if a process crashes | 109 * termination due to some system event. E.g. if a process crashes |
110 * due to an access violation the 32-bit exit code is `0xc0000005`, | 110 * due to an access violation the 32-bit exit code is `0xc0000005`, |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 * Returns the standard input stream of the process as an [IOSink]. | 247 * Returns the standard input stream of the process as an [IOSink]. |
248 */ | 248 */ |
249 IOSink get stdin; | 249 IOSink get stdin; |
250 | 250 |
251 /** | 251 /** |
252 * Returns the process id of the process. | 252 * Returns the process id of the process. |
253 */ | 253 */ |
254 int get pid; | 254 int get pid; |
255 | 255 |
256 /** | 256 /** |
257 * On Windows, [kill] kills the process, ignoring the [signal] | 257 * On Linux and Mac OS, [kill] sends [signal] to the process. When the process |
258 * flag. On Posix systems, [kill] sends [signal] to the | 258 * terminates as a result of calling [kill], the value for [exitCode] may be a |
259 * process. Depending on the signal send, it'll have different | 259 * negative number corresponding to the provided [signal]. |
260 * meanings. When the process terminates as a result of calling | |
261 * [kill], the [exitCode] future is completed with the exit code. | |
262 * | 260 * |
263 * Returns [:true:] if the process is successfully killed (the | 261 * On Windows, [kill] kills the process, ignoring the [signal] flag. |
264 * signal is successfully sent). Returns [:false:] if the process | 262 * |
265 * could not be killed (the signal could not be sent). Usually, | 263 * Returns [:true:] if the signal is successfully sent and process is killed. |
266 * a [:false:] return value from kill means that the process is | 264 * Otherwise the signal could not be sent, usually meaning that the process is |
267 * already dead. | 265 * already dead. |
268 */ | 266 */ |
269 bool kill([ProcessSignal signal = ProcessSignal.SIGTERM]); | 267 bool kill([ProcessSignal signal = ProcessSignal.SIGTERM]); |
270 } | 268 } |
271 | 269 |
272 | 270 |
273 /** | 271 /** |
274 * [ProcessResult] represents the result of running a non-interactive | 272 * [ProcessResult] represents the result of running a non-interactive |
275 * process started with [:Process.run:]. | 273 * process started with [:Process.run:]. |
276 */ | 274 */ |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
390 final int errorCode; | 388 final int errorCode; |
391 | 389 |
392 const ProcessException(this.executable, this.arguments, [this.message = "", | 390 const ProcessException(this.executable, this.arguments, [this.message = "", |
393 this.errorCode = 0]); | 391 this.errorCode = 0]); |
394 String toString() { | 392 String toString() { |
395 var msg = (message == null) ? 'OS error code: $errorCode' : message; | 393 var msg = (message == null) ? 'OS error code: $errorCode' : message; |
396 var args = arguments.join(' '); | 394 var args = arguments.join(' '); |
397 return "ProcessException: $msg\n Command: $executable $args"; | 395 return "ProcessException: $msg\n Command: $executable $args"; |
398 } | 396 } |
399 } | 397 } |
OLD | NEW |