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

Side by Side Diff: runtime/bin/process.dart

Issue 11343009: Get rid of 'close' on process. It is very easy to use incorrectly and cut off data from your stream… (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Remove isolate import. Created 8 years, 1 month 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
« no previous file with comments | « no previous file | runtime/bin/process_impl.dart » ('j') | runtime/bin/process_impl.dart » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 /** Exit the Dart VM process with the given [status] code. */ 5 /** Exit the Dart VM process with the given [status] code. */
6 void exit(int status) { 6 void exit(int status) {
7 if (status is !int) { 7 if (status is !int) {
8 throw new ArgumentError("int status expected"); 8 throw new ArgumentError("int status expected");
9 } 9 }
10 _exit(status); 10 _exit(status);
11 } 11 }
12 12
13 /** 13 /**
14 * [Process] is used to start new processes using the static 14 * [Process] is used to start new processes using the static
15 * [start] and [run] methods. 15 * [start] and [run] methods.
16 */ 16 */
17 class Process { 17 class Process {
18 /** 18 /**
19 * Starts a process running the [executable] with the specified 19 * Starts a process running the [executable] with the specified
20 * [arguments]. Returns a [:Future<Process>:] that completes with a 20 * [arguments]. Returns a [:Future<Process>:] that completes with a
21 * Process instance when the process has been successfully 21 * Process instance when the process has been successfully
22 * started. That [Process] object can be used to interact with the 22 * started. That [Process] object can be used to interact with the
23 * process. If the process cannot be started the returned [Future] 23 * process. If the process cannot be started the returned [Future]
24 * completes with an exception. 24 * completes with an exception.
25 * 25 *
26 * An optional [ProcessOptions] object can be passed to specify 26 * An optional [ProcessOptions] object can be passed to specify
27 * options other than the executable and the arguments. 27 * options other than the executable and the arguments.
28 *
29 * Users must read all data coming on the [stdout] and [stderr]
30 * streams of processes started with [:Process.start:]. If the user
31 * does not read all data on the streams the underlying system
32 * resources will not be freed since there is still pending data.
28 */ 33 */
29 static Future<Process> start(String executable, 34 static Future<Process> start(String executable,
30 List<String> arguments, 35 List<String> arguments,
31 [ProcessOptions options]) { 36 [ProcessOptions options]) {
32 return _Process.start(executable, arguments, options); 37 return _Process.start(executable, arguments, options);
33 } 38 }
34 39
35 /** 40 /**
36 * Starts a process and runs it non-interactively to completion. The 41 * Starts a process and runs it non-interactively to completion. The
37 * process run is [executable] with the specified [arguments]. 42 * process run is [executable] with the specified [arguments].
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 * meanings. When the process terminates as a result of calling 94 * meanings. When the process terminates as a result of calling
90 * [kill] [onExit] is called. 95 * [kill] [onExit] is called.
91 * 96 *
92 * Returns [:true:] if the process is successfully killed (the 97 * Returns [:true:] if the process is successfully killed (the
93 * signal is successfully sent). Returns [:false:] if the process 98 * signal is successfully sent). Returns [:false:] if the process
94 * could not be killed (the signal could not be sent). Usually, 99 * could not be killed (the signal could not be sent). Usually,
95 * a [:false:] return value from kill means that the process is 100 * a [:false:] return value from kill means that the process is
96 * already dead. 101 * already dead.
97 */ 102 */
98 abstract bool kill([ProcessSignal signal = ProcessSignal.SIGTERM]); 103 abstract bool kill([ProcessSignal signal = ProcessSignal.SIGTERM]);
99
100 /**
101 * Terminates the streams of a process. [close] must be called on a
102 * process to free the system resources associated with it if not all
103 * data on the stdout and stderr streams have been read. Usually,
104 * close should be called in [onExit], but care must be taken to actually
105 * wait on the stderr and stdout streams to close if all data is required.
106 * Once a process has been closed it can no longer be killed and [onExit]
107 * is detached so the application is not notified of process termination.
108 */
109 abstract void close();
110 } 104 }
111 105
112 106
113 /** 107 /**
114 * [ProcessResult] represents the result of running a non-interactive 108 * [ProcessResult] represents the result of running a non-interactive
115 * process started with [:Process.run:]. 109 * process started with [:Process.run:].
116 */ 110 */
117 abstract class ProcessResult { 111 abstract class ProcessResult {
118 /** 112 /**
119 * Exit code for the process. 113 * Exit code for the process.
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 /** 218 /**
225 * Contains the system message for the process exception if any. 219 * Contains the system message for the process exception if any.
226 */ 220 */
227 final String message; 221 final String message;
228 222
229 /** 223 /**
230 * Contains the OS error code for the process exception if any. 224 * Contains the OS error code for the process exception if any.
231 */ 225 */
232 final int errorCode; 226 final int errorCode;
233 } 227 }
OLDNEW
« no previous file with comments | « no previous file | runtime/bin/process_impl.dart » ('j') | runtime/bin/process_impl.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698