Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 /** | 5 /** |
| 6 * [Process] objects are used to start new processes and interact with | 6 * [Process] objects are used to start new processes and interact with |
| 7 * them. | 7 * them. |
| 8 */ | 8 */ |
| 9 interface Process default _Process { | 9 interface Process default _Process { |
| 10 /** | 10 /** |
| 11 * Creates a new process object and starts a process running the | 11 * Creates a new process object and starts a process running the |
| 12 * [executable] with the specified [arguments]. When the process has | 12 * [executable] with the specified [arguments]. When the process has |
| 13 * been successfully started [onStart] is called. If the process | 13 * been successfully started [onStart] is called. If the process |
| 14 * fails to start [onError] is called. | 14 * fails to start [onError] is called. |
| 15 * | 15 * |
| 16 * An optional [workingDirectory] can be passed to specify where the process | 16 * An optional [workingDirectory] can be passed to specify where the process |
| 17 * is run from. Note that the change of directory occurs before executing | 17 * is run from. Note that the change of directory occurs before executing |
| 18 * the process on some platforms, which may have impact when using relative | 18 * the process on some platforms, which may have impact when using relative |
| 19 * paths for [executable] and [arguments]. | 19 * paths for [executable] and [arguments]. |
| 20 * | 20 * |
| 21 * No data can be written to the process stdin and the process | 21 * No data can be written to the process stdin and the process |
| 22 * cannot be closed nor killed before [onStart] has been invoked. | 22 * cannot be closed nor killed before [onStart] has been invoked. |
| 23 */ | 23 */ |
| 24 Process.start(String executable, | 24 Process.start(String executable, |
| 25 List<String> arguments, | 25 List<String> arguments, |
| 26 [String workingDirectory]); | 26 [String workingDirectory]); |
| 27 | 27 |
| 28 /** | 28 /** |
| 29 * Creates a new process object and starts a process running the | |
|
zundel
2012/03/27 00:51:55
Why didn't you didn't create a subclass of Process
zundel
2012/03/27 12:33:21
I see now the relationship is inverted to what I o
Mads Ager (google)
2012/03/27 16:56:32
I see your point Eric. However, I think that havin
zundel
2012/03/27 17:48:29
This is more work for you, so I can understand why
Mads Ager (google)
2012/03/27 18:09:43
I'm not sure I follow your suggestion. You still h
| |
| 30 * [executable] with the specified [arguments]. When the process has | |
| 31 * been successfully started [onStart] is called. If the process | |
| 32 * fails to start [onError] is called. | |
| 33 * | |
| 34 * [workingDirectory] specify where the process is run from. Note | |
| 35 * that the change of directory occurs before executing the process | |
| 36 * on some platforms, which may have impact when using relative | |
| 37 * paths for [executable] and [arguments]. | |
| 38 * | |
| 39 * No communication via [stdin], [stdout] or [stderr] can take place | |
| 40 * with a non-interactive process. Instead, the process is run to | |
| 41 * completion at which point the exit code and stdout and stderr are | |
| 42 * supplied to the [callback] parameter. | |
| 43 */ | |
| 44 Process.startNonInteractive(String executable, | |
|
Bob Nystrom
2012/03/27 00:20:01
"startNonInteractive" is a mouthful. Maybe just "r
Mads Ager (google)
2012/03/27 00:33:25
Yes, will do. The comment should state in the firs
Søren Gjesse
2012/03/27 07:03:23
The callback provides stdout and stderr as strings
Mads Ager (google)
2012/03/27 16:56:32
Adding support for specifying an encoding of the o
| |
| 45 List<String> arguments, | |
| 46 String workingDirectory, | |
|
Bob Nystrom
2012/03/27 00:20:01
Seeing this repeated list of arguments between thi
Mads Ager (google)
2012/03/27 00:33:25
I completely agree that we need a better way of ha
Mads Ager (google)
2012/03/27 00:46:00
I would like to keep the simple case very easy. So
Søren Gjesse
2012/03/27 07:03:23
I am not sure about the ProcessOptions argument -
Mads Ager (google)
2012/03/27 16:56:32
I think what it buys is that you get away from the
| |
| 47 void callback(int exitCode, | |
| 48 String stdout, | |
| 49 String stderr)); | |
| 50 | |
| 51 /** | |
| 29 * Returns an input stream of the process stdout. | 52 * Returns an input stream of the process stdout. |
| 53 * | |
| 54 * Throws a [ProcessException] if the process is non-interactive. | |
|
Bob Nystrom
2012/03/27 00:20:01
I don't think this should be a ProcessException. A
Mads Ager (google)
2012/03/27 00:33:25
Sure, I'll change that.
Søren Gjesse
2012/03/27 07:03:23
Maybe we should consider one of two:
1. make the
Mads Ager (google)
2012/03/27 16:56:32
That would be a possibility. However, since you ar
| |
| 30 */ | 55 */ |
| 31 InputStream get stdout(); | 56 InputStream get stdout(); |
| 32 | 57 |
| 33 /** | 58 /** |
| 34 * Returns an input stream of the process stderr. | 59 * Returns an input stream of the process stderr. |
| 60 * | |
| 61 * Throws a [ProcessException] if the process is non-interactive. | |
| 35 */ | 62 */ |
| 36 InputStream get stderr(); | 63 InputStream get stderr(); |
| 37 | 64 |
| 38 /** | 65 /** |
| 39 * Returns an output stream to the process stdin. | 66 * Returns an output stream to the process stdin. |
| 67 * | |
| 68 * Throws a [ProcessException] if the process is non-interactive. | |
| 40 */ | 69 */ |
| 41 OutputStream get stdin(); | 70 OutputStream get stdin(); |
| 42 | 71 |
| 43 /** | 72 /** |
| 44 * Set the start handler which gets invoked when the process is | 73 * Set the start handler which gets invoked when the process is |
| 45 * successfully started. | 74 * successfully started. |
| 46 */ | 75 */ |
| 47 void set onStart(void callback()); | 76 void set onStart(void callback()); |
| 48 | 77 |
| 49 /** | 78 /** |
| 50 * Sets an exit handler which gets invoked when the process terminates. | 79 * Sets an exit handler which gets invoked when the process |
| 80 * terminates. | |
| 81 * | |
| 82 * Throws a [ProcessException] if the process is non-interactive. | |
| 51 */ | 83 */ |
| 52 void set onExit(void callback(int exitCode)); | 84 void set onExit(void callback(int exitCode)); |
| 53 | 85 |
| 54 /** | 86 /** |
| 55 * Set an error handler which gets invoked if an operation on the process | 87 * Set an error handler which gets invoked if an operation on the process |
| 56 * fails. | 88 * fails. |
| 57 */ | 89 */ |
| 58 void set onError(void callback(ProcessException error)); | 90 void set onError(void callback(ProcessException error)); |
| 59 | 91 |
| 60 /** | 92 /** |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 82 /** | 114 /** |
| 83 * Contains the system message for the process exception if any. | 115 * Contains the system message for the process exception if any. |
| 84 */ | 116 */ |
| 85 final String message; | 117 final String message; |
| 86 | 118 |
| 87 /** | 119 /** |
| 88 * Contains the OS error code for the process exception if any. | 120 * Contains the OS error code for the process exception if any. |
| 89 */ | 121 */ |
| 90 final int errorCode; | 122 final int errorCode; |
| 91 } | 123 } |
| OLD | NEW |