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

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.
53 * 54 *
54 * The exit code is global for the Dart VM and the last assignment to 55 * 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 56 * exitCode from any isolate determines the exit code of the Dart VM
56 * on normal termination. 57 * on normal termination.
Søren Gjesse 2014/03/14 12:04:49 Maybe mention that the default value is 0.
Anders Johnsen 2014/03/17 10:40:06 Done.
57 * 58 *
58 * See [exit] for more information on how to chose a value for the 59 * See [exit] for more information on how to chose a value for the
59 * exit code. 60 * exit code.
60 */ 61 */
61 set exitCode(int code) { 62 set exitCode(int code) {
62 if (code is !int) { 63 if (code is !int) {
63 throw new ArgumentError("Integer value for exit code expected"); 64 throw new ArgumentError("Integer value for exit code expected");
64 } 65 }
65 _ProcessUtils._setExitCode(code); 66 _ProcessUtils._setExitCode(code);
66 } 67 }
67 68
69 /*
70 * Get the global exit code for the Dart VM.
71 *
72 * The exit code is global for the Dart VM and the last assignment to
73 * exitCode from any isolate determines the exit code of the Dart VM
74 * on normal termination.
75 *
76 * See [exit] for more information on how to chose a value for the
77 * exit code.
78 */
79 get exitCode => _ProcessUtils._getExitCode();
Søren Gjesse 2014/03/14 12:04:49 Add return type.
Anders Johnsen 2014/03/17 10:40:06 Done.
80
68 /** 81 /**
69 * Sleep for the duration specified in [duration]. 82 * Sleep for the duration specified in [duration].
70 * 83 *
71 * Use this with care, as no asynchronous operations can be processed 84 * Use this with care, as no asynchronous operations can be processed
72 * in a isolate while it is blocked in a [sleep] call. 85 * in a isolate while it is blocked in a [sleep] call.
73 */ 86 */
74 void sleep(Duration duration) { 87 void sleep(Duration duration) {
75 int milliseconds = duration.inMilliseconds; 88 int milliseconds = duration.inMilliseconds;
76 if (milliseconds < 0) { 89 if (milliseconds < 0) {
77 throw new ArgumentError("sleep: duration cannot be negative"); 90 throw new ArgumentError("sleep: duration cannot be negative");
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after
491 final int errorCode; 504 final int errorCode;
492 505
493 const ProcessException(this.executable, this.arguments, [this.message = "", 506 const ProcessException(this.executable, this.arguments, [this.message = "",
494 this.errorCode = 0]); 507 this.errorCode = 0]);
495 String toString() { 508 String toString() {
496 var msg = (message == null) ? 'OS error code: $errorCode' : message; 509 var msg = (message == null) ? 'OS error code: $errorCode' : message;
497 var args = arguments.join(' '); 510 var args = arguments.join(' ');
498 return "ProcessException: $msg\n Command: $executable $args"; 511 return "ProcessException: $msg\n Command: $executable $args";
499 } 512 }
500 } 513 }
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