Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(182)

Side by Side Diff: sdk/lib/io/process.dart

Issue 200233002: Add exitCode getter counterpart to the existing setter in dart:io. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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);
11 external static void _setExitCode(int status); 11 external static void _setExitCode(int status);
12 external static int _getExitCode();
12 external static void _sleep(int millis); 13 external static void _sleep(int millis);
13 external static int _pid(Process process); 14 external static int _pid(Process process);
14 external static Stream<ProcessSignal> _watchSignal(ProcessSignal signal); 15 external static Stream<ProcessSignal> _watchSignal(ProcessSignal signal);
15 } 16 }
16 17
17 /** 18 /**
18 * Exit the Dart VM process immediately with the given exit code. 19 * Exit the Dart VM process immediately with the given exit code.
19 * 20 *
20 * This does not wait for any asynchronous operations to terminate. Using 21 * This does not wait for any asynchronous operations to terminate. Using
21 * [exit] is therefore very likely to lose data. 22 * [exit] is therefore very likely to lose data.
(...skipping 20 matching lines...) Expand all
42 * cross-platform issues. 43 * cross-platform issues.
43 */ 44 */
44 void exit(int code) { 45 void exit(int code) {
45 if (code is !int) { 46 if (code is !int) {
46 throw new ArgumentError("Integer value for exit code expected"); 47 throw new ArgumentError("Integer value for exit code expected");
47 } 48 }
48 _ProcessUtils._exit(code); 49 _ProcessUtils._exit(code);
49 } 50 }
50 51
51 /** 52 /**
52 * Global exit code for the Dart VM. 53 * Set the global exit code for the Dart VM.
54 *
55 * The exit code is global for the Dart VM and the last assignment to
56 * exitCode from any isolate determines the exit code of the Dart VM
57 * on normal termination.
58 *
59 * Default value is `0`.
60 *
61 * See [exit] for more information on how to chose a value for the
62 * exit code.
63 */
64 void set exitCode(int code) {
65 if (code is !int) {
66 throw new ArgumentError("Integer value for exit code expected");
67 }
68 _ProcessUtils._setExitCode(code);
69 }
70
71 /*
72 * Get the global exit code for the Dart VM.
53 * 73 *
54 * The exit code is global for the Dart VM and the last assignment to 74 * The exit code is global for the Dart VM and the last assignment to
55 * exitCode from any isolate determines the exit code of the Dart VM 75 * exitCode from any isolate determines the exit code of the Dart VM
56 * on normal termination. 76 * on normal termination.
57 * 77 *
58 * See [exit] for more information on how to chose a value for the 78 * See [exit] for more information on how to chose a value for the
59 * exit code. 79 * exit code.
60 */ 80 */
61 set exitCode(int code) { 81 int get exitCode => _ProcessUtils._getExitCode();
62 if (code is !int) {
63 throw new ArgumentError("Integer value for exit code expected");
64 }
65 _ProcessUtils._setExitCode(code);
66 }
67 82
68 /** 83 /**
69 * Sleep for the duration specified in [duration]. 84 * Sleep for the duration specified in [duration].
70 * 85 *
71 * Use this with care, as no asynchronous operations can be processed 86 * Use this with care, as no asynchronous operations can be processed
72 * in a isolate while it is blocked in a [sleep] call. 87 * in a isolate while it is blocked in a [sleep] call.
73 */ 88 */
74 void sleep(Duration duration) { 89 void sleep(Duration duration) {
75 int milliseconds = duration.inMilliseconds; 90 int milliseconds = duration.inMilliseconds;
76 if (milliseconds < 0) { 91 if (milliseconds < 0) {
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after
491 final int errorCode; 506 final int errorCode;
492 507
493 const ProcessException(this.executable, this.arguments, [this.message = "", 508 const ProcessException(this.executable, this.arguments, [this.message = "",
494 this.errorCode = 0]); 509 this.errorCode = 0]);
495 String toString() { 510 String toString() {
496 var msg = (message == null) ? 'OS error code: $errorCode' : message; 511 var msg = (message == null) ? 'OS error code: $errorCode' : message;
497 var args = arguments.join(' '); 512 var args = arguments.join(' ');
498 return "ProcessException: $msg\n Command: $executable $args"; 513 return "ProcessException: $msg\n Command: $executable $args";
499 } 514 }
500 } 515 }
OLDNEW
« no previous file with comments | « sdk/lib/_internal/lib/io_patch.dart ('k') | tests/standalone/io/process_set_exit_code_script.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698