| 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 23 matching lines...) Expand all Loading... |
| 34 * Besides this the Dart executable itself uses an exit code of `254` | 34 * Besides this the Dart executable itself uses an exit code of `254` |
| 35 * for reporting compile time errors and an exit code of `255` for | 35 * for reporting compile time errors and an exit code of `255` for |
| 36 * reporting runtime error (unhandled exception). | 36 * reporting runtime error (unhandled exception). |
| 37 * | 37 * |
| 38 * Due to these facts it is recommended to only use exit codes in the | 38 * Due to these facts it is recommended to only use exit codes in the |
| 39 * range [0..127] for communicating the result of running a Dart | 39 * range [0..127] for communicating the result of running a Dart |
| 40 * program to the surrounding environment. This will avoid any | 40 * program to the surrounding environment. This will avoid any |
| 41 * cross-platform issues. | 41 * cross-platform issues. |
| 42 */ | 42 */ |
| 43 void exit(int code) { | 43 void exit(int code) { |
| 44 if (status is !int) { | 44 if (code is !int) { |
| 45 throw new ArgumentError("exit: int status expected"); | 45 throw new ArgumentError("Integer value for exit code expected"); |
| 46 } | 46 } |
| 47 _ProcessUtils._exit(status); | 47 _ProcessUtils._exit(code); |
| 48 } | 48 } |
| 49 | 49 |
| 50 /** | 50 /** |
| 51 * Global exit code for the Dart VM. | 51 * Global exit code for the Dart VM. |
| 52 * | 52 * |
| 53 * The exit code is global for the Dart VM and the last assignment to | 53 * The exit code is global for the Dart VM and the last assignment to |
| 54 * exitCode from any isolate determines the exit code of the Dart VM | 54 * exitCode from any isolate determines the exit code of the Dart VM |
| 55 * on normal termination. | 55 * on normal termination. |
| 56 * | 56 * |
| 57 * See [exit] for more information on how to chose a value for the | 57 * See [exit] for more information on how to chose a value for the |
| 58 * exit code. | 58 * exit code. |
| 59 */ | 59 */ |
| 60 set exitCode(int code) { | 60 set exitCode(int code) { |
| 61 if (status is !int) { | 61 if (code is !int) { |
| 62 throw new ArgumentError("setExitCode: int status expected"); | 62 throw new ArgumentError("Integer value for exit code expected"); |
| 63 } | 63 } |
| 64 _ProcessUtils._setExitCode(status); | 64 _ProcessUtils._setExitCode(code); |
| 65 } | 65 } |
| 66 | 66 |
| 67 /** | 67 /** |
| 68 * Sleep for the duration specified in [duration]. | 68 * Sleep for the duration specified in [duration]. |
| 69 * | 69 * |
| 70 * Use this with care, as no asynchronous operations can be processed | 70 * Use this with care, as no asynchronous operations can be processed |
| 71 * in a isolate while it is blocked in a [sleep] call. | 71 * in a isolate while it is blocked in a [sleep] call. |
| 72 */ | 72 */ |
| 73 void sleep(Duration duration) { | 73 void sleep(Duration duration) { |
| 74 int milliseconds = duration.inMilliseconds; | 74 int milliseconds = duration.inMilliseconds; |
| (...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 368 /** | 368 /** |
| 369 * Contains the system message for the process exception if any. | 369 * Contains the system message for the process exception if any. |
| 370 */ | 370 */ |
| 371 final String message; | 371 final String message; |
| 372 | 372 |
| 373 /** | 373 /** |
| 374 * Contains the OS error code for the process exception if any. | 374 * Contains the OS error code for the process exception if any. |
| 375 */ | 375 */ |
| 376 final int errorCode; | 376 final int errorCode; |
| 377 } | 377 } |
| OLD | NEW |