OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
424 * Returns `true` if the signal is successfully delivered to the | 424 * Returns `true` if the signal is successfully delivered to the |
425 * process. Otherwise the signal could not be sent, usually meaning | 425 * process. Otherwise the signal could not be sent, usually meaning |
426 * that the process is already dead. | 426 * that the process is already dead. |
427 */ | 427 */ |
428 bool kill([ProcessSignal signal = ProcessSignal.SIGTERM]); | 428 bool kill([ProcessSignal signal = ProcessSignal.SIGTERM]); |
429 } | 429 } |
430 | 430 |
431 | 431 |
432 /** | 432 /** |
433 * [ProcessResult] represents the result of running a non-interactive | 433 * [ProcessResult] represents the result of running a non-interactive |
434 * process started with [:Process.run:]. | 434 * process started with [Process.run] or [Process.runSync]. |
435 */ | 435 */ |
436 abstract class ProcessResult { | 436 class ProcessResult { |
437 /** | 437 /** |
438 * Exit code for the process. | 438 * Exit code for the process. |
439 * | 439 * |
440 * See [Process.exitCode] for more information in the exit code | 440 * See [Process.exitCode] for more information in the exit code |
441 * value. | 441 * value. |
442 */ | 442 */ |
443 int get exitCode; | 443 final int exitCode; |
444 | 444 |
445 /** | 445 /** |
446 * Standard output from the process. The value used for the | 446 * Standard output from the process. The value used for the |
447 * `stdoutEncoding` argument to `Process.run` determines the type. If | 447 * `stdoutEncoding` argument to `Process.run` determines the type. If |
448 * `null` was used this value is of type `List<int> otherwise it is | 448 * `null` was used this value is of type `List<int> otherwise it is |
449 * of type `String`. | 449 * of type `String`. |
450 */ | 450 */ |
451 get stdout; | 451 final stdout; |
452 | 452 |
453 /** | 453 /** |
454 * Standard error from the process. The value used for the | 454 * Standard error from the process. The value used for the |
455 * `stderrEncoding` argument to `Process.run` determines the type. If | 455 * `stderrEncoding` argument to `Process.run` determines the type. If |
456 * `null` was used this value is of type `List<int> | 456 * `null` was used this value is of type `List<int> |
457 * otherwise it is of type `String`. | 457 * otherwise it is of type `String`. |
458 */ | 458 */ |
459 get stderr; | 459 final stderr; |
460 | 460 |
461 /** | 461 /** |
462 * Process id from the process. | 462 * Process id of the process. |
463 */ | 463 */ |
464 int get pid; | 464 final int pid; |
| 465 |
| 466 ProcessResult(this.pid, this.exitCode, this.stdout, this.stderr); |
465 } | 467 } |
466 | 468 |
467 | 469 |
468 /** | 470 /** |
469 * On Posix systems, [ProcessSignal] is used to send a specific signal | 471 * On Posix systems, [ProcessSignal] is used to send a specific signal |
470 * to a child process, see [:Process.kill:]. | 472 * to a child process, see [:Process.kill:]. |
471 * | 473 * |
472 * Some [ProcessSignal]s can also be watched, as a way to intercept the default | 474 * Some [ProcessSignal]s can also be watched, as a way to intercept the default |
473 * signal handler and implement another. See [ProcessSignal.watch] for more | 475 * signal handler and implement another. See [ProcessSignal.watch] for more |
474 * information. | 476 * information. |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
570 final int errorCode; | 572 final int errorCode; |
571 | 573 |
572 const ProcessException(this.executable, this.arguments, [this.message = "", | 574 const ProcessException(this.executable, this.arguments, [this.message = "", |
573 this.errorCode = 0]); | 575 this.errorCode = 0]); |
574 String toString() { | 576 String toString() { |
575 var msg = (message == null) ? 'OS error code: $errorCode' : message; | 577 var msg = (message == null) ? 'OS error code: $errorCode' : message; |
576 var args = arguments.join(' '); | 578 var args = arguments.join(' '); |
577 return "ProcessException: $msg\n Command: $executable $args"; | 579 return "ProcessException: $msg\n Command: $executable $args"; |
578 } | 580 } |
579 } | 581 } |
OLD | NEW |