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

Unified Diff: runtime/bin/process.dart

Issue 9024008: Change the process API to be completely asynchronous. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add binaries. Created 9 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | runtime/bin/process_impl.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/process.dart
diff --git a/runtime/bin/process.dart b/runtime/bin/process.dart
index 50d8fc0628143334f85119ee679760e88112f9b0..9faca406fe8ad6d85186bba465c4dc72703e8203 100644
--- a/runtime/bin/process.dart
+++ b/runtime/bin/process.dart
@@ -3,47 +3,62 @@
// BSD-style license that can be found in the LICENSE file.
interface Process default _Process {
- /*
- * Creates a new process object preparing to run the executable
- * found at [path] with the specified [arguments].
+ /**
+ * Creates a new process object and starts a process running the executable
+ * found at [path] with the specified [arguments]. When the process has
+ * been successfully started the [startHandler] is called. If the process
+ * fails to start the [errorHandler] is called.
+ *
+ * No data can be written to the process stdin and the process cannot be
+ * closed nor killed before the [startHandler] has been invoked.
*/
- Process(String path, List<String> arguments);
+ Process.start(String path, List<String> arguments);
- /*
- * Start the process by running the specified executable. An
- * exception of type [ProcessException] is thrown if the process
- * cannot be started. There is a remote possibility of an exception
- * being thrown even though the child process did actually start.
- */
- void start();
-
- /*
+ /**
* Returns an input stream of the process stdout.
*/
InputStream get stdout();
- /*
+ /**
* Returns an input stream of the process stderr.
*/
InputStream get stderr();
- /*
+ /**
* Returns an output stream to the process stdin.
*/
OutputStream get stdin();
- /*
+ /**
+ * Set the start handler which gets invoked when the process is
+ * successfully started.
+ */
+ void set startHandler(void callback());
+
+ /**
* Sets an exit handler which gets invoked when the process terminates.
*/
void set exitHandler(void callback(int exitCode));
- /*
- * Kills the process with [signal].
+ /**
+ * Set an error handler which gets invoked if an operation on the process
+ * fails.
+ */
+ void set errorHandler(void callback(ProcessException error));
+
+ /**
+ * Kills the process. When the process terminates as a result of calling
+ * [kill] the [exitHandler] is called. If the kill operation fails, the
+ * [errorHandler] is called.
*/
- bool kill();
+ void kill();
- /*
- * Terminates the streams and closes the exit handler of a process.
+ /**
+ * Terminates the streams of a process. [close] most be called on a process
+ * to free the system resources associated with it. Usually, close should be
+ * called in the [exitHandler]. Once a process has been closed it can no
+ * longer be killed and the [exitHandler] is detached so the application is
+ * not notified of process termination.
*/
void close();
}
@@ -53,12 +68,12 @@ class ProcessException implements Exception {
const ProcessException([String this.message, int this.errorCode = 0]);
String toString() => "ProcessException: $message";
- /*
+ /**
* Contains the system message for the process exception if any.
*/
final String message;
- /*
+ /**
* Contains the OS error code for the process exception if any.
*/
final int errorCode;
« no previous file with comments | « no previous file | runtime/bin/process_impl.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698