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

Unified Diff: sdk/lib/io/process.dart

Issue 890633002: Add an option for starting a detached process with stdio connected (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rebased Created 5 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/bin/process_win.cc ('k') | tests/standalone/io/process_detached_script.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/io/process.dart
diff --git a/sdk/lib/io/process.dart b/sdk/lib/io/process.dart
index a977b319b6173dd8bfe70d0cf62bfb952217c7ad..e64d064307765acca00005d1599a098038426361 100644
--- a/sdk/lib/io/process.dart
+++ b/sdk/lib/io/process.dart
@@ -100,6 +100,19 @@ void sleep(Duration duration) {
int get pid => _ProcessUtils._pid(null);
/**
+ * Modes for running a new process.
+ */
+enum ProcessStartMode {
+ /// Normal child process.
+ NORMAL,
+ /// Detached child process with no open communication channel.
+ DETACHED,
+ /// Detached child process with stdin, stdout and stderr still open
+ /// for communication with the child.
+ DETACHED_WITH_STDIO
+}
+
+/**
* The means to execute a program.
*
* Use the static [start] and [run] methods to start a new process.
@@ -248,7 +261,7 @@ abstract class Process {
* Users must read all data coming on the [stdout] and [stderr]
* streams of processes started with [:Process.start:]. If the user
* does not read all data on the streams the underlying system
- * resources will not be freed since there is still pending data.
+ * resources will not be released since there is still pending data.
*
* The following code uses `Process.start` to grep for `main` in the
* file `test.dart` on Linux.
@@ -258,12 +271,25 @@ abstract class Process {
* stderr.addStream(process.stderr);
* });
*
- * If [detach] is `true` a detached process will be created. A
- * detached process has no connection to its parent, and can
- * keep running on its own when the parent dies. The only
+ * If [mode] is [ProcessStartMode.NORMAL] (the default) a child
+ * process will be started with `stdin`, `stdout` and `stderr`
+ * connected.
+ *
+ * If `mode` is [ProcessStartMode.DETACHED] a detached process will
+ * be created. A detached process has no connection to its parent,
+ * and can keep running on its own when the parent dies. The only
* information available from a detached process is its `pid`. There
- * is no connection to its `stdin`, `stdout` or `stderr` nor will its
- * exit code become available when it terminates.
+ * is no connection to its `stdin`, `stdout` or `stderr`, nor will
+ * the process' exit code become available when it terminates.
+ *
+ * If `mode` is [ProcessStartMode.DETACHED_WITH_STDIO] a detached
+ * process will be created where the `stdin`, `stdout` and `stderr`
+ * are connected. The creator can communicate with the child through
+ * these. The detached process will keep running even if these
+ * communication channels are closed. The process' exit code will
+ * not become available when it terminated.
+ *
+ * The default value for `mode` is `ProcessStartMode.NORMAL`.
*/
external static Future<Process> start(
String executable,
@@ -272,7 +298,7 @@ abstract class Process {
Map<String, String> environment,
bool includeParentEnvironment: true,
bool runInShell: false,
- bool detach: false});
+ ProcessStartMode mode: ProcessStartMode.NORMAL});
/**
* Starts a process and runs it non-interactively to completion. The
« no previous file with comments | « runtime/bin/process_win.cc ('k') | tests/standalone/io/process_detached_script.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698